Explore the association between SES factors and early-life factors (Figure 1)

Generate SES Index using CFA model (SES at enrollment) (Figure 1a)

rm(list=ls())
library(polycor)
library(psych)
library(circlize)
library(lavaan)
library(semTools)
library(colorspace)
library(ggplot2)
library(tibble)
library(limma)
library(tidyverse)
library(patchwork)
work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"
setwd(work.dir)
############################################################################################
load("Results/P00 Clinical data process.RData")
set.seed(3243432)
pa1.vars <- c("income_pre" ,"meducationhighest_pre18w","deducationhighest_pre18w",
              "canadaladder_pre18w", "communityladder_pre18w")
update.model <- '
meducationhighest_pre18w ~~ deducationhighest_pre18w
canadaladder_pre18w ~~   communityladder_pre18w 
'
pa.model.1 <- paste0("PA",1,"_latent =~   ", paste(get(paste0("pa",1,".vars")),collapse="+"))
set.seed(3243432)
data.ana <- na.omit(data.all[,c("subjectnumber",pa1.vars)])
individual.cfa.raw <- cfa(paste(pa.model.1, update.model, sep="\n"),  
                          data=data.ana,
                          ordered=c("income_pre","meducationhighest_pre18w","deducationhighest_pre18w"))
#(modindices(individual.cfa.raw, alpha=0.05, sort=T))
summary(individual.cfa.raw, standard=T,fit=T)
## lavaan 0.6-19 ended normally after 30 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        20
## 
##   Number of observations                          2752
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 2.788       8.825
##   Degrees of freedom                                 3           3
##   P-value (Chi-square)                           0.426       0.032
##   Scaling correction factor                                  0.321
##   Shift parameter                                            0.130
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                              6945.424    4811.292
##   Degrees of freedom                                10          10
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.444
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       0.999
##   Tucker-Lewis Index (TLI)                       1.000       0.996
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.000       0.027
##   90 Percent confidence interval - lower         0.000       0.007
##   90 Percent confidence interval - upper         0.031       0.048
##   P-value H_0: RMSEA <= 0.050                    0.999       0.968
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.008       0.008
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   PA1_latent =~                                                         
##     income_pre        1.000                               0.732    0.732
##     mdctnhghst_p18    0.834    0.031   26.564    0.000    0.610    0.610
##     ddctnhghst_p18    0.729    0.032   23.067    0.000    0.534    0.534
##     candlddr_pr18w    1.492    0.060   24.850    0.000    1.092    0.712
##     cmmntylddr_p18    0.959    0.058   16.392    0.000    0.702    0.438
## 
## Covariances:
##                               Estimate  Std.Err  z-value  P(>|z|)   Std.lv
##  .meducationhighest_pre18w ~~                                             
##    .ddctnhghst_p18               0.287    0.019   15.443    0.000    0.287
##  .canadaladder_pre18w ~~                                                  
##    .cmmntylddr_p18               0.582    0.045   12.840    0.000    0.582
##   Std.all
##          
##     0.428
##          
##     0.375
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .candlddr_pr18w    6.777    0.033  208.167    0.000    6.777    4.417
##    .cmmntylddr_p18    6.711    0.035  193.395    0.000    6.711    4.190
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     income_pre|t1    -1.097    0.030  -36.656    0.000   -1.097   -1.097
##     income_pre|t2    -0.078    0.024   -3.278    0.001   -0.078   -0.078
##     income_pre|t3     0.678    0.026   26.072    0.000    0.678    0.678
##     mdctnhghs_18|1   -1.423    0.035  -40.490    0.000   -1.423   -1.423
##     mdctnhghs_18|2   -0.360    0.024  -14.719    0.000   -0.360   -0.360
##     mdctnhghs_18|3    0.864    0.027   31.501    0.000    0.864    0.864
##     ddctnhghs_18|1   -1.066    0.030  -36.081    0.000   -1.066   -1.066
##     ddctnhghs_18|2   -0.057    0.024   -2.363    0.018   -0.057   -0.057
##     ddctnhghs_18|3    0.999    0.029   34.725    0.000    0.999    0.999
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .income_pre        0.464                               0.464    0.464
##    .mdctnhghst_p18    0.628                               0.628    0.628
##    .ddctnhghst_p18    0.715                               0.715    0.715
##    .candlddr_pr18w    1.160    0.052   22.395    0.000    1.160    0.493
##    .cmmntylddr_p18    2.073    0.062   33.631    0.000    2.073    0.808
##     PA1_latent        0.536    0.025   21.367    0.000    1.000    1.000
PA1_latent.raw <- lavPredict(individual.cfa.raw)
data.ses.mr.raw <- data.frame(subjectnumber = data.ana$subjectnumber, 
                              MR1_latent.raw = PA1_latent.raw[,1])
data.ses.mr <- data.ses.mr.raw
data.withmissing <- data.all[,c("subjectnumber",colnames(data.all)[colnames(data.all)%in%all.vars.use$Vars])]
data.withmissing <- merge(data.withmissing, data.ses.mr,by="subjectnumber",all=T)

data.withmissing$income_pre_num <- as.numeric(data.withmissing$income_pre)
data.withmissing$meducationhighest_pre18w_num <- as.numeric(data.withmissing$meducationhighest_pre18w)
data.withmissing$deducationhighest_pre18w_num <- as.numeric(data.withmissing$deducationhighest_pre18w)

#Different way of generating ses index - using PCA analysis
# data.try <- data.withmissing[,c("subjectnumber","income_pre_num","meducationhighest_pre18w_num","deducationhighest_pre18w_num","communityladder_pre18w","canadaladder_pre18w")]
# data.try <- na.omit(data.try)
# rownames(data.try) <- data.try$subjectnumber
# data.try <- data.try[,c("income_pre_num","meducationhighest_pre18w_num","deducationhighest_pre18w_num","communityladder_pre18w","canadaladder_pre18w")]
# 
# pca.m <- prcomp(data.try,scale. = T)
# pca.m$rotation
# summ <- summary(pca.m)
# weights <- summ$importance[2,]
# data.try1 <- data.frame(pc.avg1=apply(pca.m$x[,1,drop=F],1,mean))
# data.try2 <- data.frame(pc.avg2=apply(pca.m$x[,1:2,drop=F], 1, function(x) sum(x * weights[1:2])))
# data.try3 <- data.frame(pc.avg3=apply(pca.m$x[,1:3,drop=F], 1, function(x) sum(x * weights[1:3])))
# data.try5 <-data.frame(pc.avg5=apply(pca.m$x[,1:5,drop=F], 1, function(x) sum(x * weights[1:5])))
# 
# data.try <- cbind(data.try1,data.try2,data.try3,data.try5)
# dd.kk <- merge(data.ses.mr.raw, data.try5,by.x="subjectnumber", by.y="row.names")
# library(reshape2)
# library(ggpubr)
# dd.kk.long <- melt(dd.kk, id.vars=c("subjectnumber","MR1_latent.raw"))
# ggplot(dd.kk.long, aes(MR1_latent.raw,value))+
#   geom_point()+
#   facet_wrap(~variable,scale="free")+stat_cor(method="pearson")
# data.withmissing <- merge(data.withmissing, data.try5, by.x="subjectnumber", by.y="row.names",all.x=T)

Generate SES Index at 1 year using CFA model (assocaited with SES index at enrollment correlation=0.86)

#1y SES cfa Model
pa1.vars <- c("income_1y" ,"meducationhighest_1y","deducationhighest_1y",
              "canadaladder_1y", "communityladder_1y")
update.model <- '
meducationhighest_1y ~~ deducationhighest_1y
canadaladder_1y ~~   communityladder_1y 
'
pa.model.1 <- paste0("PA",1,"_latent =~   ", paste(get(paste0("pa",1,".vars")),collapse="+"))
set.seed(3243432)
data.ana <- na.omit(data.all[,c("subjectnumber",pa1.vars)])
individual.cfa.raw <- cfa(paste(pa.model.1, update.model, sep="\n"),  
                          data=data.ana,
                          ordered=c("income_1y","meducationhighest_1y","deducationhighest_1y"))
summary(individual.cfa.raw, standard=T,fit=T)
## lavaan 0.6-19 ended normally after 31 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                        20
## 
##   Number of observations                          2191
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                                 4.537      14.120
##   Degrees of freedom                                 3           3
##   P-value (Chi-square)                           0.209       0.003
##   Scaling correction factor                                  0.324
##   Shift parameter                                            0.105
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                              4745.897    3313.744
##   Degrees of freedom                                10          10
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.433
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    1.000       0.997
##   Tucker-Lewis Index (TLI)                       0.999       0.989
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.015       0.041
##   90 Percent confidence interval - lower         0.000       0.021
##   90 Percent confidence interval - upper         0.042       0.064
##   P-value H_0: RMSEA <= 0.050                    0.988       0.710
##   P-value H_0: RMSEA >= 0.080                    0.000       0.002
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.011       0.011
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   PA1_latent =~                                                         
##     income_1y         1.000                               0.706    0.706
##     medctnhghst_1y    0.790    0.040   19.699    0.000    0.557    0.557
##     dedctnhghst_1y    0.699    0.041   17.249    0.000    0.493    0.493
##     canadaladdr_1y    1.521    0.082   18.469    0.000    1.074    0.706
##     commntylddr_1y    1.040    0.073   14.178    0.000    0.734    0.471
## 
## Covariances:
##                           Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##  .meducationhighest_1y ~~                                                      
##    .dedctnhghst_1y           0.321    0.021   15.250    0.000    0.321    0.445
##  .canadaladder_1y ~~                                                           
##    .commntylddr_1y           0.661    0.054   12.287    0.000    0.661    0.446
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .canadaladdr_1y    6.825    0.036  190.280    0.000    6.825    4.486
##    .commntylddr_1y    6.776    0.038  177.793    0.000    6.776    4.350
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     income_1y|t1     -1.054    0.033  -31.974    0.000   -1.054   -1.054
##     income_1y|t2      0.099    0.027    3.695    0.000    0.099    0.099
##     income_1y|t3      0.878    0.031   28.430    0.000    0.878    0.878
##     mdctnhghst_1|1   -1.494    0.041  -36.398    0.000   -1.494   -1.494
##     mdctnhghst_1|2   -0.410    0.028  -14.843    0.000   -0.410   -0.410
##     mdctnhghst_1|3    0.839    0.031   27.496    0.000    0.839    0.839
##     ddctnhghst_1|1   -1.105    0.034  -32.824    0.000   -1.105   -1.105
##     ddctnhghst_1|2   -0.076    0.027   -2.840    0.005   -0.076   -0.076
##     ddctnhghst_1|3    0.960    0.032   30.210    0.000    0.960    0.960
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .income_1y         0.502                               0.502    0.502
##    .medctnhghst_1y    0.689                               0.689    0.689
##    .dedctnhghst_1y    0.757                               0.757    0.757
##    .canadaladdr_1y    1.162    0.067   17.407    0.000    1.162    0.502
##    .commntylddr_1y    1.888    0.069   27.504    0.000    1.888    0.778
##     PA1_latent        0.498    0.032   15.812    0.000    1.000    1.000
PA1_latent.raw <- lavPredict(individual.cfa.raw)
data.ses.mr.raw <- data.frame(subjectnumber =data.ana$subjectnumber, 
                              MR1_latent.raw.1y = PA1_latent.raw[,1])
data.ses.mr <- data.ses.mr.raw
data.withmissing <- merge(data.withmissing, data.ses.mr,by="subjectnumber",all=T)

#SES Pregnancy and SES at 1 year index are high associated
with(data.withmissing, cor(MR1_latent.raw,MR1_latent.raw.1y,use="pairwise"))
## [1] 0.8625438
#Clean the data
cleanData <- function(data.ana){
  data.ana$income_pre_num <- as.numeric(unclass(as.factor(data.ana$income_pre)))
  data.ana$cwol <- ifelse(data.ana$birth_mode=="3.cwol",1,0)
  data.ana$cwl <- ifelse(data.ana$birth_mode=="2.cwl",1,0)
  data.ana$vaginal <- ifelse(data.ana$birth_mode=="1.vaginal",1,0)
  data.ana$mom_education_highest_num <- as.numeric(unclass(as.factor(data.ana$meducationhighest_pre18w)))
  data.ana$dad_education_highest_num <- as.numeric(unclass(as.factor(data.ana$deducationhighest_pre18w)))
  data.ana$race_dad <- relevel(as.factor(data.ana$race_dad), ref="Caucasian White")
  data.ana$race_mom <- relevel(as.factor(data.ana$race_mom), ref="Caucasian White")
  data.ana$causacian_mom <- ifelse(data.ana$race_mom=="Caucasian White",1,0)
  data.ana$causacian_dad <- ifelse(data.ana$race_dad=="Caucasian White",1,0)
  data.ana$summer <- ifelse(data.ana$Season=="2.Summer",1,0)
  data.ana$fall <- ifelse(data.ana$Season=="3.Fall",1,0)
  data.ana$winter <- ifelse(data.ana$Season=="4.Winter",1,0)
  data.ana$vancouver <- ifelse(data.ana$site=="vancouver",1,0)
  data.ana$toronto  <- ifelse(data.ana$site=="toronto",1,0)
  data.ana$winnipeg  <- ifelse(data.ana$site=="winnipeg",1,0)
  data.ana$edmonton  <- ifelse(data.ana$site=="edmonton",1,0)
  data.ana$atbx.1y.time[data.ana$atbx.1y==0& !is.na(data.ana$atbx.1y)] <- 999
  return(data.ana)
}
data.withmissing <- cleanData(data.withmissing)
cutpoints <- quantile(data.withmissing$MR1_latent.raw,na.rm=T)
cutpoints[1] <- min(data.withmissing$MR1_latent.raw,na.rm=T)-0.1
cutpoints[5] <- max(data.withmissing$MR1_latent.raw,na.rm=T)+0.1
data.withmissing$cat_SES <- cut(data.withmissing$MR1_latent.raw,
                                breaks=cutpoints,
                                labels=c('1.0-25%', '2.25-50%', '3.50-75%', '4.75-100%'),na.rm=T)
data.withmissing$MR1_latent.raw.interquartile <- data.withmissing$MR1_latent.raw/(cutpoints[4]-cutpoints[2])
data.withmissing$EBF_6m <- ifelse(data.withmissing$ebf_duration>=6,1,0)

data.withmissing$SES_EBFcompound <- ifelse(data.withmissing$MR1_latent.raw>cutpoints[3] & data.withmissing$EBF_6m==1,"4.High SES w/ EBF to 6m",
                                      ifelse(data.withmissing$MR1_latent.raw>cutpoints[3] & data.withmissing$EBF_6m==0,"3.High SES w/o EBF to 6m",
                                             ifelse(data.withmissing$MR1_latent.raw<cutpoints[3] & data.withmissing$EBF_6m==1, "2.Low SES w/ EBF to 6m",
                                                    ifelse(data.withmissing$MR1_latent.raw<cutpoints[3] & data.withmissing$EBF_6m==0, "1.Low SES w/o EBF to 6m",NA)))) 

cutpoints.1y <- quantile(data.withmissing$MR1_latent.raw.1y,na.rm=T)
cutpoints.1y[1] <- min(data.withmissing$MR1_latent.raw.1y,na.rm=T)-0.1
cutpoints.1y[5] <- max(data.withmissing$MR1_latent.raw.1y,na.rm=T)+0.1
data.withmissing$cat_SES.1y <- cut(data.withmissing$MR1_latent.raw.1y,
                                breaks=cutpoints.1y,
                                labels=c('1.0-25%', '2.25-50%', '3.50-75%', '4.75-100%'),na.rm=T)
data.withmissing$MR1_latent.raw.interquartile.1y <- data.withmissing$MR1_latent.raw.1y/(cutpoints.1y[4]-cutpoints.1y[2])

data.map <- rbind(data.map,
                  data.frame(Vars=c("MR1_latent.raw", "MR1_latent.raw.1y",
                                    "MR1_latent.raw.interquartile","MR1_latent.raw.interquartile.1y",
                                    "dad_education_highest_num" ,
                                    "mom_education_highest_num",
                                    "income_pre_num",
                                     "SES_EBFcompound"),
                             Category=c(rep("SES",8)),
                             Label=c("SES Index","SES Index (1y)",
                                     "SES Index","SES Index (1y)",
                                     "Education of father",
                                     "Education of mother",
                                     "Income",
                                     "SES and Breastfeeding Group"),
                             Type=c(rep("Continuous",7),"Categorical"),
                             Values=NA))

data.map <- unique(data.map)
save(data.withmissing,
     output.vars, clic.vars, data.map,
     file="Results/P0 Clinical data with SES Index.RData")

Generate Demographic table (Table S1)

###########################################################################################
#demographic table
used.vars <- c("asthma5y_ep","atopy5y","Tscore_abnormal","overweight",
               "atbx.1y", "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
              "awayhome1h_3m", "bf_duration_imp","EBF_6m","bw_sd", "canue_Zdweldensity_pre18w" ,
              "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
              "dog_1y", "fasthma","father_atopy_1y",
              "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
              "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
              "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
              "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
              "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", 
              "birth_mode", "Season",
               "MR1_latent.raw","meducationhighest_pre18w","deducationhighest_pre18w","income_pre", "canadaladder_pre18w", "communityladder_pre18w",
                "MR1_latent.raw.1y","income_1y" ,"meducationhighest_1y","deducationhighest_1y", "canadaladder_1y", "communityladder_1y",
               "race_dad","race_mom","site","male")
# ,
#               "bfhistory_m","bfhistory_m_time",
#                                   "bfhistory_f","bfhistory_f_time",
#                "PBscore",
#                                     "WSscore",
#                                     "BAscore","eaPBscore",
#                                     "eaWSscore" ,                   
#                                     "eaBAscore",
#                                     "pb_sumscore",
#                                     "ws_sumscore",
#                                     "ba_sumscore"  ,                
#                                     "eapb_sumscore",
#                                     "eaws_sumscore",
#                                     "eaba_sumscore")
used.vars.demo <- used.vars
#Dictionary for demographic table and forest plot
level.dictionary <- c("2.cwl" = "C-section with labor",
                      "3.cwol" = "C-section without labor",
                      "1.vaginal" = "Vaginal",
                      
                      "1.Spring" = "Spring",
                      "2.Summer" = "Summer",
                      "3.Fall" = "Fall",
                      "4.Winter" = "Winter",
                      
                      "4.High SES w/ EBF to 6m" =  "High SES w/ EBF to 6m",
                      "3.High SES w/o EBF to 6m" = "High SES w/o EBF to 6m" ,
                      "2.Low SES w/ EBF to 6m" =   "Low SES w/ EBF to 6m",
                      "1.Low SES w/o EBF to 6m" = "Low SES w/o EBF to 6m")

map.labels <- c(as.character(data.map$Label))
names(map.labels) <- c(as.character(data.map$Vars))

cate.vars.all <- data.map$Vars[data.map$Type=="Categorical"]
cont.vars.all <- data.map$Vars[data.map$Type=="Continuous"]

demo.tab1 <- demo.fuc(data.demo = data.withmissing,
                      cate.vars = used.vars.demo[used.vars.demo%in%cate.vars.all],
                      cont.vars = c("MR1_latent.raw",used.vars.demo[used.vars.demo%in%cont.vars.all]),
                      subg.var = NA,
                      comp.p=F,
                      dic.demo = map.labels,
                      na.option = "Exclude",
                      dic.level = level.dictionary)

demo.tab1.na <- demo.fuc(data.demo = data.withmissing,
                         cate.vars = used.vars.demo[used.vars.demo%in%cate.vars.all],
                         cont.vars = c("MR1_latent.raw",used.vars.demo[used.vars.demo%in%cont.vars.all]),
                         subg.var = NA,
                         comp.p=F,
                         dic.demo = map.labels,
                         na.option = "Include",
                         dic.level = level.dictionary)
demo.tab1.na <- subset(demo.tab1.na, Variable=="Unknown")
demo.tab1 <- rbind(demo.tab1, demo.tab1.na)
demo.tab1 <- demo.tab1[order(demo.tab1$Map),]
demo.tab1 <- merge(demo.tab1, data.map, by.x="Map", by.y="Vars",all.x=T,sort = F)
demo.tab1 <- demo.tab1[,c("Category","Variable","Cohort","Map")]


demo.tab1.use <- demo.tab1

demo.tab1.use$Category[is.na(demo.tab1.use$Category)] <- "no.patient"
demo.tab1.use$Category <- factor(demo.tab1.use$Category, levels=c("no.patient","SES","Ethnicity","Health",
                                                                  "Birth", "Pregnancy",  "Postnatal" ,
                                                                  "Home Environment"  , "Neighbourhood Environment","Parental Diet/Health" ),
                                 ordered=T)
demo.tab1.use <- subset(demo.tab1.use, !Category%in%c("Ethnicity"))
write.csv(demo.tab1.use, "Results/Demographic table.csv")
demo.tab1.use <- demo.tab1.use[order(demo.tab1.use$Category),c("Variable","Cohort")]
demo.tab1.use
##                                Variable            Cohort
## 231                        No. patients              3263
## 31          Social status (Canada) (1y)                  
## 32                       Median (Range)         7 (1, 10)
## 33                          IQR (Q1,Q3)              6, 8
## 34                              Unknown       738 (22.6%)
## 35               Social status (Canada)                  
## 36                       Median (Range)         7 (1, 10)
## 37                          IQR (Q1,Q3)              6, 8
## 38                              Unknown        190 (5.8%)
## 46       Social status (community) (1y)                  
## 47                       Median (Range)         7 (1, 10)
## 48                          IQR (Q1,Q3)              6, 8
## 49                              Unknown       737 (22.6%)
## 50            Social status (community)                  
## 51                       Median (Range)         7 (1, 10)
## 52                          IQR (Q1,Q3)              6, 8
## 53                              Unknown        193 (5.9%)
## 56       Education of father (1y), n(%)                  
## 57                         1.highschool       466 (15.2%)
## 58                            2.college      1022 (33.3%)
## 59                         3.university        1073 (35%)
## 60                        4.masterorphd       508 (16.6%)
## 61                              Unknown        194 (5.9%)
## 62            Education of father, n(%)                  
## 63                         1.highschool       475 (15.3%)
## 64                            2.college      1038 (33.5%)
## 65                         3.university      1096 (35.3%)
## 66                        4.masterorphd       494 (15.9%)
## 67                              Unknown        160 (4.9%)
## 88                    Income (1y), n(%)                  
## 89                            1.0-49999       368 (15.6%)
## 90                          2.5000-9999         917 (39%)
## 91                      3.100000-149999       631 (26.8%)
## 92                         4.150000over       436 (18.5%)
## 93                              Unknown       911 (27.9%)
## 94                         Income, n(%)                  
## 95                            1.0-49999       399 (14.1%)
## 96                          2.5000-9999       943 (33.2%)
## 97                      3.100000-149999         795 (28%)
## 98                         4.150000over       700 (24.7%)
## 99                              Unknown       426 (13.1%)
## 113      Education of mother (1y), n(%)                  
## 114                        1.highschool        271 (8.7%)
## 115                           2.college       894 (28.8%)
## 116                        3.university      1340 (43.1%)
## 117                       4.masterorphd       603 (19.4%)
## 118                             Unknown        155 (4.8%)
## 119           Education of mother, n(%)                  
## 120                        1.highschool        276 (8.8%)
## 121                           2.college       905 (28.9%)
## 122                        3.university      1353 (43.2%)
## 123                       4.masterorphd       598 (19.1%)
## 124                             Unknown          131 (4%)
## 219                           SES Index                  
## 220                      Median (Range)   0.1 (-2.4, 1.6)
## 221                         IQR (Q1,Q3)         -0.4, 0.4
## 222                           SES Index                  
## 223                      Median (Range)   0.1 (-2.4, 1.6)
## 224                         IQR (Q1,Q3)         -0.4, 0.4
## 225                             Unknown       511 (15.7%)
## 226                             Unknown       511 (15.7%)
## 227                      SES Index (1y)                  
## 228                      Median (Range)   0.1 (-2.4, 1.6)
## 229                         IQR (Q1,Q3)         -0.4, 0.4
## 230                             Unknown      1072 (32.9%)
## 9                     Atopy at 5y, n(%)                  
## 10                                            494 (19.3%)
## 11                              Unknown       708 (21.7%)
## 210                 Aasthma at 5y, n(%)                  
## 211                                            165 (6.9%)
## 212                             Unknown       864 (26.5%)
## 213              Overweight at 5y, n(%)                  
## 214                                           542 (20.6%)
## 215                             Unknown       638 (19.6%)
## 216 Abnormal child behavior at 5y, n(%)                  
## 217                                            172 (7.3%)
## 218                             Unknown       903 (27.7%)
## 4         Intrapartum antibiotics, n(%)                  
## 5                                               651 (27%)
## 6                               Unknown       856 (26.2%)
## 22                  Delivery mode, n(%)                  
## 23                              Vaginal      2412 (74.8%)
## 24                 C-section with labor       425 (13.2%)
## 25              C-section without labor         387 (12%)
## 26                              Unknown         39 (1.2%)
## 27                 Birth weight Z score                  
## 28                       Median (Range)  -0.1 (-3.1, 4.3)
## 29                          IQR (Q1,Q3)         -0.7, 0.5
## 30                              Unknown         75 (2.3%)
## 81                      Gestational age                  
## 82                       Median (Range)    278 (238, 300)
## 83                          IQR (Q1,Q3)          272, 283
## 84                              Unknown         54 (1.7%)
## 185               Season of birth, n(%)                  
## 186                              Spring       889 (27.2%)
## 187                              Summer       830 (25.4%)
## 188                                Fall       754 (23.1%)
## 189                              Winter       790 (24.2%)
## 7    Maternal antibiotics (preg.), n(%)                  
## 8                                              314 (9.6%)
## 54           Gestational diabetes, n(%)                  
## 55                                             154 (4.7%)
## 109           Maternal distress (preg.)                  
## 110                      Median (Range)        13 (0, 35)
## 111                         IQR (Q1,Q3)             9, 17
## 112                             Unknown         325 (10%)
## 155              Prenatal smoking, n(%)                  
## 156                                           606 (19.1%)
## 157                             Unknown           97 (3%)
## 1            Antibiotics use (1y), n(%)                  
## 2                                             619 (26.1%)
## 3                               Unknown       890 (27.3%)
## 12    Reg. childcare attend. (1y), n(%)                  
## 13                                            735 (28.5%)
## 14                              Unknown       688 (21.1%)
## 15    Reg. childcare attend. (3m), n(%)                  
## 16                                            338 (11.3%)
## 17                              Unknown        274 (8.4%)
## 18               Any breastfeeding dur.                  
## 19                       Median (Range)        10 (0, 30)
## 20                          IQR (Q1,Q3)             5, 14
## 21                              Unknown        106 (3.2%)
## 43                      Pet (cat), n(%)                  
## 44                                            550 (21.4%)
## 45                              Unknown       690 (21.1%)
## 68                      Pet (dog), n(%)                  
## 69                                            701 (27.1%)
## 70                              Unknown       681 (20.9%)
## 144                  Older siblings (#)                  
## 145                      Median (Range)          0 (0, 4)
## 146                         IQR (Q1,Q3)              0, 1
## 147                             Unknown        101 (3.1%)
## 148             Postnatal smoking, n(%)                  
## 149                                           620 (23.1%)
## 150                             Unknown       578 (17.7%)
## 195  Exclusive breastfeeding (6m), n(%)                  
## 196                                           522 (17.1%)
## 197                             Unknown        208 (6.4%)
## 77                 Cleaning product use                  
## 78                       Median (Range)        31 (4, 76)
## 79                          IQR (Q1,Q3)            25, 38
## 80                              Unknown       341 (10.5%)
## 85               Multifamily home, n(%)                  
## 86                                            878 (28.9%)
## 87                              Unknown        223 (6.8%)
## 198                  Clutter home, n(%)                  
## 199                                           581 (19.1%)
## 200                             Unknown          229 (7%)
## 201                  Potted plant, n(%)                  
## 202                                          1822 (59.9%)
## 203                             Unknown        223 (6.8%)
## 204                  Carpet floor, n(%)                  
## 205                                          1722 (56.6%)
## 206                             Unknown        223 (6.8%)
## 207             Medium/high mould, n(%)                  
## 208                                           359 (11.8%)
## 209                             Unknown        223 (6.8%)
## 39                     Dwelling density                  
## 40                       Median (Range)  0.2 (-0.8, 10.7)
## 41                          IQR (Q1,Q3)         -0.2, 1.4
## 42                              Unknown          197 (6%)
## 136         Air pollution (NO2) (preg.)                  
## 137                      Median (Range)  10.6 (1.3, 35.8)
## 138                         IQR (Q1,Q3)           5.3, 15
## 139                             Unknown        191 (5.9%)
## 140            Air pollution (NO2) (1y)                  
## 141                      Median (Range)   9.1 (0.5, 30.5)
## 142                         IQR (Q1,Q3)         4.6, 13.3
## 143                             Unknown        194 (5.9%)
## 151                Tree density (preg.)                  
## 152                      Median (Range)        20 (0, 99)
## 153                         IQR (Q1,Q3)            13, 32
## 154                             Unknown       663 (20.3%)
## 182                         Rural, n(%)                  
## 183                                              186 (6%)
## 184                             Unknown        146 (4.5%)
## 71                Paternal asthma, n(%)                  
## 72                                            510 (19.2%)
## 73                              Unknown       600 (18.4%)
## 74                 Paternal atopy, n(%)                  
## 75                                           1663 (67.7%)
## 76                              Unknown       806 (24.7%)
## 102               Maternal asthma, n(%)                  
## 103                                           749 (23.4%)
## 104                             Unknown         56 (1.7%)
## 105              Maternal distress (1y)                  
## 106                      Median (Range)        12 (0, 40)
## 107                         IQR (Q1,Q3)             7, 17
## 108                             Unknown         685 (21%)
## 125                        Maternal BMI                  
## 126                      Median (Range) 23.3 (13.9, 56.9)
## 127                         IQR (Q1,Q3)            21, 27
## 128                             Unknown         327 (10%)
## 129                   Maternal UPF diet                  
## 130                      Median (Range)  46.8 (1.9, 82.9)
## 131                         IQR (Q1,Q3)        39.7, 53.8
## 132                             Unknown        291 (8.9%)
## 133                Maternal atopy, n(%)                  
## 134                                          1727 (57.7%)
## 135                             Unknown        268 (8.2%)
## 100                          Male, n(%)                  
## 101                                          1717 (52.6%)
## 190                  Study center, n(%)                  
## 191                            edmonton       768 (23.5%)
## 192                             toronto       768 (23.5%)
## 193                           vancouver       735 (22.5%)
## 194                            winnipeg       992 (30.4%)
#Load in the package and function and data
data.use <- data.withmissing
#################################################################################################################
#Used early-life factors and their labels
used.vars <- c("atbx.1y", "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
              "awayhome1h_3m", "bf_duration_imp","bw_sd", "canue_Zdweldensity_pre18w" ,
              "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
              "dog_1y", "EBF_6m", "fasthma","father_atopy_1y",
              "freq_score_basic", "gest_days", "hometype_3m", "masthma","maternaldistress_perceived_1y",
              "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
              "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
              "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
              "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter")

all.vars.use <- c(used.vars,"dad_education_highest_num","mom_education_highest_num",
                  "income_pre_num","communityladder_pre18w",
                  "canadaladder_pre18w")
data.map.use <- data.map
rownames(data.map.use) <- data.map.use$Vars

#Scale variables
data.fa.scale <- data.use[,c(all.vars.use)]
for(i in 1:ncol(data.fa.scale)){
  data.fa.scale[,i] <- as.numeric(as.factor(data.fa.scale[,i]))
}
data.fa.scale <- scale(data.fa.scale)
X <-  data.fa.scale[,c(all.vars.use)]
colnames(X) <- data.map.use[all.vars.use,"Label"]

#Calculate correlation
kk <- cor(X, use="pairwise", method="pearson")
result_new <- kk
pdf("Figures/P2 SES Icluster of factors.pdf", height=12, width=12)
iclust(X)
dev.off()

Generate Tree diagram of Item Cluster analysis (ICLUST) (Figure S1b)

iclust(X)

## ICLUST (Item Cluster Analysis)
## Call: iclust(r.mat = X)
## 
## Purified Alpha:
##  C27  C32  C29   C6  C24  C15  C11  C30   C8  C10   C1 
## 0.72 0.75 0.47 0.67 0.25 0.28 0.50 0.27 0.31 0.30 0.30 
## 
## G6* reliability:
##  C27  C32  C29   C6  C24  C15  C11  C30   C8  C10   C1 
## 0.54 0.83 0.50 1.00 0.59 1.00 0.25 0.48 1.00 1.00 1.00 
## 
## Original Beta:
##  C27  C32  C29   C6  C24  C15  C11  C30   C8  C10   C1 
## 0.46 0.32 0.35 0.67 0.19 0.28 0.50 0.19 0.31 0.30 0.30 
## 
## Cluster size:
## C27 C32 C29  C6 C24 C15 C11 C30  C8 C10  C1 
##   8   8   5   2   4   2   2   6   2   2   2 
## 
## Item by Cluster Structure matrix:
##                                O   P   C27   C32   C29    C6   C24   C15   C11
## Antibiotics use (1y)         C30 C27  0.10 -0.06  0.13  0.08  0.13 -0.01 -0.03
## Intrapartum antibiotics      C30 C27 -0.06  0.02 -0.03  0.00  0.04 -0.01  0.02
## Maternal antibiotics (preg.) C30 C27  0.03 -0.03  0.04  0.05  0.02 -0.01 -0.02
## Reg. childcare attend. (1y)   C8 C27 -0.05 -0.01  0.12  0.07 -0.02 -0.01 -0.01
## Reg. childcare attend. (3m)   C8 C27 -0.01 -0.09  0.13 -0.01  0.00  0.04 -0.01
## Any breastfeeding dur.       C29 C27 -0.07  0.32 -0.55 -0.11 -0.20  0.00 -0.02
## Birth weight Z score         C24 C27  0.12 -0.07  0.08  0.01  0.30  0.03 -0.05
## Dwelling density             C27 C27 -0.74  0.30 -0.22 -0.10 -0.24  0.15  0.04
## Pet (cat)                    C24 C32  0.01 -0.10  0.03  0.04  0.21  0.20 -0.01
## Gestational diabetes         C30 C32 -0.01 -0.07  0.06  0.03  0.12  0.02  0.03
## Pet (dog)                    C29 C32  0.14 -0.07  0.23 -0.04  0.11 -0.03  0.01
## Exclusive breastfeeding (6m) C29 C32 -0.01  0.14 -0.38 -0.06 -0.06  0.01 -0.07
## Paternal asthma               C1 C32  0.01 -0.01  0.01  0.00 -0.03  0.02  0.05
## Paternal atopy                C1 C32 -0.12  0.08 -0.10  0.03 -0.12 -0.01 -0.02
## Cleaning product use         C29 C32  0.03 -0.12  0.45  0.07  0.15 -0.14  0.00
## Gestational age              C30 C32  0.00  0.05 -0.08 -0.03  0.09 -0.07 -0.05
## Multifamily home             C27 C29 -0.38 -0.03 -0.25  0.05 -0.15  0.31  0.04
## Maternal asthma              C10 C29  0.03 -0.06  0.09  0.11  0.13  0.08  0.03
## Maternal distress (1y)        C6 C29  0.04 -0.23  0.08  0.62  0.05  0.20  0.00
## Maternal distress (preg.)     C6 C29  0.08 -0.37  0.16  0.66  0.09  0.16  0.04
## Maternal BMI                 C24 C29  0.17 -0.28  0.32  0.13  0.38  0.17  0.06
## Maternal UPF diet            C29  C6  0.12 -0.27  0.33  0.17  0.16 -0.04  0.01
## Maternal atopy               C10  C6 -0.15  0.09 -0.04  0.01 -0.09  0.05 -0.03
## Air pollution (NO2) (preg.)  C27 C24 -0.88  0.30 -0.13 -0.08 -0.16  0.07 -0.14
## Air pollution (NO2) (1y)     C27 C24 -0.84  0.29 -0.09 -0.06 -0.19  0.10 -0.01
## Older siblings (#)           C27 C24  0.25 -0.11 -0.03  0.05  0.16  0.05 -0.04
## Postnatal smoking            C32 C24  0.07 -0.54  0.37  0.23  0.23  0.20  0.01
## Tree density (preg.)         C27 C15 -0.49  0.26  0.03 -0.12 -0.15  0.06  0.05
## Prenatal smoking             C32 C15  0.09 -0.52  0.33  0.22  0.19  0.18 -0.01
## Rural                        C27 C11  0.29 -0.18  0.10  0.00  0.04 -0.08  0.00
## Clutter home                 C15 C11  0.02 -0.22  0.00  0.19  0.20  0.40  0.03
## Potted plant                 C32 C30 -0.09  0.21 -0.17 -0.15 -0.09 -0.09  0.01
## Carpet floor                 C27 C30  0.27 -0.11  0.07  0.03  0.00 -0.14 -0.02
## Medium/high mould            C15 C30 -0.17 -0.04 -0.08  0.02  0.02  0.33 -0.03
## Vaginal delivery             C30 C30  0.10 -0.01 -0.10 -0.03 -0.11  0.01  0.02
## Born in fall                 C24 C30 -0.02  0.01 -0.01  0.03 -0.36  0.02  0.01
## Born in summer               C11 C30  0.01 -0.02 -0.03  0.01  0.30  0.04 -0.56
## Born in winter               C11  C8  0.00 -0.02  0.03  0.04  0.29  0.03  0.60
## Education of father          C32  C8 -0.34  0.61 -0.37 -0.17 -0.28 -0.14  0.01
## Education of mother          C32 C10 -0.32  0.67 -0.40 -0.20 -0.29 -0.16 -0.01
## Income                       C32 C10 -0.28  0.59 -0.03 -0.35 -0.15 -0.39 -0.01
## Social status (community)    C32  C1 -0.17  0.48 -0.18 -0.30 -0.16 -0.10  0.01
## Social status (Canada)       C32  C1 -0.23  0.67 -0.20 -0.38 -0.23 -0.25  0.02
##                                C30    C8   C10    C1
## Antibiotics use (1y)          0.24  0.01  0.07  0.00
## Intrapartum antibiotics       0.17  0.06  0.04 -0.03
## Maternal antibiotics (preg.)  0.17  0.00 -0.01 -0.05
## Reg. childcare attend. (1y)   0.06  0.36  0.11  0.06
## Reg. childcare attend. (3m)  -0.03  0.34  0.09 -0.03
## Any breastfeeding dur.       -0.19 -0.20  0.04  0.10
## Birth weight Z score          0.11 -0.09 -0.01 -0.11
## Dwelling density             -0.03 -0.02  0.08  0.10
## Pet (cat)                    -0.08 -0.01  0.00 -0.05
## Gestational diabetes          0.26  0.01  0.00 -0.02
## Pet (dog)                     0.02  0.12  0.00 -0.07
## Exclusive breastfeeding (6m) -0.08 -0.14  0.00  0.07
## Paternal asthma              -0.01  0.02  0.03  0.33
## Paternal atopy               -0.05  0.01 -0.01  0.36
## Cleaning product use          0.19  0.09  0.08  0.01
## Gestational age              -0.39  0.05 -0.06  0.04
## Multifamily home              0.01 -0.01 -0.02 -0.04
## Maternal asthma               0.12  0.07  0.35  0.00
## Maternal distress (1y)        0.09  0.09  0.12  0.01
## Maternal distress (preg.)     0.12  0.02  0.09  0.03
## Maternal BMI                  0.29  0.05  0.09 -0.03
## Maternal UPF diet             0.04  0.12  0.08 -0.01
## Maternal atopy                0.00  0.13  0.36  0.02
## Air pollution (NO2) (preg.)   0.07  0.07  0.20  0.13
## Air pollution (NO2) (1y)      0.10  0.05  0.21  0.12
## Older siblings (#)            0.06 -0.20 -0.05 -0.09
## Postnatal smoking             0.13  0.07 -0.03 -0.08
## Tree density (preg.)         -0.05 -0.02  0.03  0.06
## Prenatal smoking              0.10  0.11  0.04 -0.01
## Rural                        -0.05 -0.02 -0.06 -0.11
## Clutter home                  0.03  0.06  0.09  0.00
## Potted plant                 -0.02 -0.07  0.01  0.01
## Carpet floor                  0.03 -0.06 -0.10 -0.10
## Medium/high mould             0.00 -0.03  0.03  0.01
## Vaginal delivery             -0.19 -0.04 -0.08 -0.03
## Born in fall                  0.04 -0.02  0.01  0.07
## Born in summer               -0.05 -0.02 -0.02  0.00
## Born in winter               -0.02 -0.06 -0.02  0.05
## Education of father          -0.07 -0.17  0.00  0.05
## Education of mother          -0.09 -0.07  0.04  0.05
## Income                       -0.03 -0.04  0.11  0.22
## Social status (community)    -0.04 -0.10 -0.01 -0.01
## Social status (Canada)       -0.10 -0.01  0.03  0.05
## 
## With Sums of squares of:
##  C27  C32  C29   C6  C24  C15  C11  C30   C8  C10   C1 
## 2.74 2.31 1.26 1.06 0.98 0.75 0.72 0.58 0.44 0.40 0.38 
## 
## Purified scale intercorrelations
##  reliabilities on diagonal
##  correlations corrected for attenuation above diagonal: 
##       C27   C32   C29    C6   C24   C15   C11   C30    C8   C10    C1
## C27  0.72 -0.39  0.20  0.09  0.31 -0.19 -0.01 -0.02 -0.07 -0.15 -0.14
## C32 -0.29  0.75 -0.49 -0.43 -0.43 -0.32  0.01 -0.13 -0.13  0.03  0.09
## C29  0.12 -0.29  0.47  0.17  0.40 -0.10  0.05  0.27  0.29  0.05 -0.11
## C6   0.06 -0.30  0.10  0.67  0.11  0.23  0.02  0.14  0.06  0.12  0.03
## C24  0.13 -0.19  0.14  0.05  0.25  0.31 -0.01  0.25 -0.02  0.06 -0.19
## C15 -0.09 -0.15 -0.04  0.10  0.08  0.28 -0.01  0.03  0.03  0.13  0.01
## C11 -0.01  0.00  0.03  0.01  0.00  0.00  0.50  0.02 -0.03  0.00  0.04
## C30 -0.01 -0.06  0.09  0.06  0.07  0.01  0.01  0.27  0.04  0.14 -0.07
## C8  -0.04 -0.06  0.11  0.03 -0.01  0.01 -0.01  0.01  0.31  0.20  0.03
## C10 -0.07  0.02  0.02  0.05  0.02  0.04  0.00  0.04  0.06  0.30  0.02
## C1  -0.07  0.04 -0.04  0.01 -0.05  0.00  0.02 -0.02  0.01  0.01  0.30
## 
## Cluster fit =  0.48   Pattern fit =  0.95  RMSR =  0.04

Explore how SES index is associated with early life factors with adjustment of site and sensitivity analyses

#Extract response variables and covariates
outcome.vars <- data.map$Vars[data.map$Category=="Health"]
outcome.vars <- outcome.vars
cov.vars <- c("atbx.1y", "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
              "awayhome1h_3m", "bf_duration_imp","EBF_6m","bw_sd", "canue_Zdweldensity_pre18w" ,
              "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
              "dog_1y", "fasthma","father_atopy_1y",
              "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
              "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
              "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
              "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
              "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter",
              "bfhistory_m","bfhistory_m_time",
                                  "bfhistory_f","bfhistory_f_time",
                "PBscore",
                                    "WSscore",
                                    "BAscore","eaPBscore",
                                    "eaWSscore" ,                   
                                    "eaBAscore",
                                    "pb_sumscore",
                                    "ws_sumscore",
                                    "ba_sumscore"  ,                
                                    "eapb_sumscore",
                                    "eaws_sumscore",
                                    "eaba_sumscore",
              data.map$Vars[data.map$Category=="Breastmilk vitamin"])

ses.vars <-  c("MR1_latent.raw","MR1_latent.raw.1y","dad_education_highest_num","mom_education_highest_num",
               "mom_education_highest_1y_num","dad_education_highest1y_num",
               "income_pre_num","income_1y_num","communityladder_pre18w","communityladder_1y",
               "canadaladder_pre18w","canadaladder_1y")
cate.vars.all <- unique(c(data.map$Vars[data.map$Type=="Categorical"],"vaginal","cwol","fall","summer","winter"))
cont.vars.all <- unique(data.map$Vars[data.map$Type=="Continuous"])

res.var.uses <- c("atopy5y", "asthma5y_ep", "overweight", "Tscore_abnormal")

#Clean the data to be appropriate for the models
data.withmissing$income_1y_num <- as.numeric(data.withmissing$income_1y)
data.withmissing$mom_education_highest_1y_num <- as.numeric(data.withmissing$meducationhighest_1y)
data.withmissing$dad_education_highest1y_num <- as.numeric(data.withmissing$deducationhighest_1y)

#Generate phenotype with at least one of these SES-associated health risks
data.resp.sum <- data.withmissing[,c("asthma5y_ep", "overweight","Tscore_abnormal")]
for(i in 1:ncol(data.resp.sum)){data.resp.sum[,i] <- as.numeric(as.character(data.resp.sum[,i]))}
nomissing.sum <- apply(data.resp.sum,1,sum)
missing.sum <- apply(data.resp.sum,1,function(x)sum(x, na.rm=T))
data.withmissing$phenotype_atleast1 <- ifelse(missing.sum>=1,1, ifelse(nomissing.sum==0,0, NA))


# # Not RUN again################################################################################################
# #Univariable analysis with clinical and environmental factors
# UVA.res.outcome <- NULL
# data.use <- data.withmissing
# cov.vars.use <- c(cov.vars)
# ses.vars.use <- c("MR1_latent.raw.interquartile","MR1_latent.raw.interquartile.1y",
#                   "dad_education_highest_num","mom_education_highest_num",
#                   "income_pre_num", "communityladder_pre18w", "canadaladder_pre18w")
# 
# #Scale the data to get standardized coefficient
# 
# data.fa.scale <- data.use[,c(cov.vars.use,ses.vars.use)[c(cov.vars.use,ses.vars.use)%in%cont.vars.all]]
# for(i in 1:ncol(data.fa.scale)){
#   data.fa.scale[,i] <- as.numeric(as.character(data.fa.scale[,i]))
# }
# data.fa.scale <- scale(data.fa.scale)
# data.fa.scale <- cbind(data.use[,c("subjectnumber","site", "male","ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3",
#                                    c(cov.vars.use,ses.vars.use)[!c(cov.vars.use,ses.vars.use)%in%cont.vars.all])],
#                        data.fa.scale)
# 
# #Univariable analysis + Sensitivity analysis for each site / adjust genetic score
# for(site.use in c("all","edmonton",   "toronto", "vancouver",  "winnipeg")){#
#   used.s <- subset(data.fa.scale, site==site.use)$subjectnumber
#   if(!site.use%in%c("all","adjsite")){
#     del.vars <- names(which(apply(subset(data.fa.scale,subjectnumber%in%used.s)[,cov.vars.use],2,sd)==0))
#   }
#   for(cov.var.use in cov.vars.use){
#     #Set up which model to use, for continous response, use lm, for categorical response, use glm
#     if(cov.var.use %in% cont.vars.all){
#       func.use <- "lm"
#     }else{
#       func.use <- "glm"
#     }
# 
#     #Sensitivity analysis if or not adjust for genetic PCs
#     for(adj.genetic in c(T,F)){
#       uva.res.mr1 <- NULL
#       for(ses.var.use in ses.vars.use){
#         if(site.use=="all"){
# 
#           if(adj.genetic==T){
# 
#             uva.res.mr1.each <- UVAMVA.func(data.func=subset(data.fa.scale),
#                                             res.var=cov.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(ses.var.use,
#                                                                     "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3","site","male")),
#                                             func.type=func.use, strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }else{
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale),
#                                             res.va=cov.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(ses.var.use,"site","male")),
#                                             func.type=func.use, strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }
# 
#         }else{
# 
#           if(adj.genetic==T){
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale,subjectnumber%in%used.s),
#                                             res.va=cov.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(ses.var.use,"male",
#                                                                     "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3")),
#                                             func.type=gsub("er","",func.use), strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }else{
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale,subjectnumber%in%used.s),
#                                             res.va=cov.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(ses.var.use),"male"),
#                                             func.type=gsub("er","",func.use), strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }
#         }
# 
#         uva.res.mr1.each <- uva.res.mr1.each[!rownames(uva.res.mr1.each)%in%c("(Intercept)","male",
#                                                                               "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3"),]
#         uva.res.mr1.each$SESVar <- ses.var.use
#         uva.res.mr1 <- rbind(uva.res.mr1, uva.res.mr1.each)
#       }
#       colnames(uva.res.mr1) <- gsub("MVA","UVA",colnames(uva.res.mr1))
#       colnames(uva.res.mr1)[colnames(uva.res.mr1)=="M"] <- "U"
#       uva.res.mr1$Response <- cov.var.use
#       uva.res.mr1$Cohort <- site.use
#       uva.res.mr1$Adj.genetic <- adj.genetic
#       UVA.res.outcome <- rbind(UVA.res.outcome, uva.res.mr1)
#     }
#   }
# }
# 
# ###########################################
# UVA.res.outcome.cont <- NULL
# data.use <- data.withmissing
# cov.vars.use <- c(cov.vars)
# ses.vars.use <- c("MR1_latent.raw.interquartile","MR1_latent.raw.interquartile.1y",
#                   "dad_education_highest_num","mom_education_highest_num",
#                   "income_pre_num", "communityladder_pre18w", "canadaladder_pre18w")
# 
# #Scale the data to get standardized coefficient
# 
# data.fa.scale <- data.use[,c(cov.vars.use,ses.vars.use)]
# for(i in 1:ncol(data.fa.scale)){
#   data.fa.scale[,i] <- as.numeric(as.character(data.fa.scale[,i]))
# }
# data.fa.scale <- scale(data.fa.scale)
# data.fa.scale <- cbind(data.use[,c("subjectnumber","site", "male","ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3")],
#                        data.fa.scale)
# 
# #Univariable analysis + Sensitivity analysis for each site / adjust genetic score
# for(site.use in c("all","edmonton",   "toronto", "vancouver",  "winnipeg")){#
#   used.s <- subset(data.fa.scale, site==site.use)$subjectnumber
#   if(!site.use%in%c("all","adjsite")){
#     del.vars <- names(which(apply(subset(data.fa.scale,subjectnumber%in%used.s)[,cov.vars.use],2,sd)==0))
#   }
#   for(cov.var.use in cov.vars.use){
#     func.use <- "lm"
# 
# 
#     #Sensitivity analysis if or not adjust for genetic PCs
#     for(adj.genetic in c(T,F)){
#       uva.res.mr1 <- NULL
#       for(ses.var.use in ses.vars.use){
#         if(site.use=="all"){
# 
#           if(adj.genetic==T){
# 
#             uva.res.mr1.each <- UVAMVA.func(data.func=subset(data.fa.scale),
#                                             res.var=ses.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(cov.var.use,
#                                                                     "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3","site","male")),
#                                             func.type=func.use, strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }else{
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale),
#                                             res.va=ses.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(cov.var.use,"site","male")),
#                                             func.type=func.use, strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }
# 
#         }else{
# 
#           if(adj.genetic==T){
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale,subjectnumber%in%used.s),
#                                             res.va=ses.var.use,digit.use=4,
#                                             conf.vars.func=unique(c(cov.var.use,"male",
#                                                                     "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3")),
#                                             func.type=gsub("er","",func.use), strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }else{
#             uva.res.mr1.each <- UVAMVA.func(subset(data.fa.scale,subjectnumber%in%used.s),
#                                             res.va=ses.var.use,digit.use=4,
#                                             conf.vars.func=unique(cov.var.use,"male"),
#                                             func.type=gsub("er","",func.use), strata=NULL,
#                                             ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#           }
#         }
# 
#         uva.res.mr1.each <- uva.res.mr1.each[!rownames(uva.res.mr1.each)%in%c("(Intercept)","male",
#                                                                               "ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3"),]
#         uva.res.mr1.each$SESVar <- ses.var.use
#         uva.res.mr1 <- rbind(uva.res.mr1, uva.res.mr1.each)
#       }
#       colnames(uva.res.mr1) <- gsub("MVA","UVA",colnames(uva.res.mr1))
#       colnames(uva.res.mr1)[colnames(uva.res.mr1)=="M"] <- "U"
#       uva.res.mr1$Response <- cov.var.use
#       uva.res.mr1$Cohort <- site.use
#       uva.res.mr1$Adj.genetic <- adj.genetic
#       UVA.res.outcome.cont <- rbind(UVA.res.outcome.cont, uva.res.mr1)
#     }
#   }
# }
# 
# Response.outcome <- NULL
# for(res.var.use in c("phenotype_atleast1",res.var.uses)){
#   used.vars <- c("MR1_latent.raw.interquartile","SES_EBFcompound",c(cov.vars))
#   data.fa.scale <- data.withmissing[,c(cov.vars[cov.vars%in%cont.vars.all])]
#   for(i in 1:ncol(data.fa.scale)){
#     data.fa.scale[,i] <- as.numeric(as.character(data.fa.scale[,i]))
#   }
#   data.fa.scale <- scale(data.fa.scale)
#   data.fa.scale <- cbind(data.withmissing[,c("subjectnumber","site", "male","ethnicity_pc1", "ethnicity_pc2", "ethnicity_pc3",
#                                              res.var.use,used.vars[!used.vars%in%colnames(data.fa.scale)])], data.fa.scale)
#   data.use <- data.fa.scale
# 
#   for(used.var in used.vars){
#     uva.res <- UVAMVA.func(data.func=data.use,
#                            res.var=res.var.use,digit.use=4,
#                            conf.vars.func=c(used.var,"male","site"),
#                            func.type="glm", strata=NULL,
#                            ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
#     uva.res$Response <- res.var.use
#     uva.res$Cohort <- "all"
#     uva.res$Cov <- used.var
#     Response.outcome <- rbind(Response.outcome,uva.res)
#   }
# }
# save(UVA.res.outcome, Response.outcome, UVA.res.outcome.cont, file="Results/P2 Univariate Analysis of SES.Rdata")
load("Results/P2 Univariate Analysis of SES.Rdata")

Generate SES index vs. early-life factors and sensitivity analysis

UVA.res.all <- subset(UVA.res.outcome.cont, !Variables%in%c("sitetoronto","male1","sitevancouver","sitewinnipeg"))
uva.res.ses.plot <- merge(subset(UVA.res.all,Response%in%used.vars),
                          data.map.use[data.map.use$Vars%in%used.vars,], by.x="Response", by.y="Vars",all.x=T)

uva.res.ses.plot$ci_low <- as.numeric(gsub("\\(","",strsplit2(uva.res.ses.plot$UVA_CI,",")[,1]))
uva.res.ses.plot$ci_high <- as.numeric(gsub("\\)","",strsplit2(uva.res.ses.plot$UVA_CI,",")[,2]))
uva.res.ses.plot$sig <- ifelse(uva.res.ses.plot$UVA_P<0.05,"sig","nosig")
uva.res.ses.plot$Direction <- ifelse(uva.res.ses.plot$UVA>0,"Positive","Negative")
uva.res.ses.plot$Category <- factor(uva.res.ses.plot$Category, levels=c("SES","Pregnancy",
                                                                        "Birth",
                                                                        "Postnatal",
                                                                        "Home Environment",
                                                                        "Neighbourhood Environment",
                                                                        "Parental Diet/Health",
                                                                        "Breastfeeding history",
                                                                        "Breastmilk vitamin"),
                                    ordered=T)
color.sh <- data.frame(Category=c("SES","Pregnancy","Birth", "Postnatal","Home Environment", "Neighbourhood Environment", "Parental Diet/Health","Breastfeeding history" ),
                       color.use=c( "#1B9E77", "#BEAED4","#E6AB02", "#BF5B17", "#386CB0", "#A6CEE3", "#F0027F","black"))

ses.plot <- ggplot(unique(subset(uva.res.ses.plot, SESVar%in%"MR1_latent.raw.interquartile" & Cohort=="all" & Adj.genetic==F)),
       aes(y=UVA, x=reorder(Label,UVA,decreasing=T),fill = Category, 
           alpha = sig)) + 
  theme_bw() + 
  ylab("Standardized coefficient") +
  geom_errorbar(aes(ymin=ci_low,ymax=ci_high), width=.2, position=position_dodge(0.5)) +
  geom_point(position=position_dodge(0.5), size = 3, pch = 21,col="black") +
  facet_grid(~Category,scale="free",space="free",labeller = label_wrap_gen(width=8)) +
  xlab("") + ggtitle("") +
  scale_shape_manual(values=seq(0,10)) +
  scale_color_manual(values = c('gray', 'black'))+
  geom_hline(yintercept = 0) + 
  scale_alpha_discrete(range = c(0.2, 1)) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+ 
  scale_fill_manual(values=c("#BEAED4", "#E6AB02", "#BF5B17", "#386CB0", "#A6CEE3", "#F0027F","black","purple"))

plot(ses.plot)

Generate ChordDiagram of SES vs. early-life factors (Figure 1b)

#Transform data for chorddiagram
ddd <- unique(subset(uva.res.ses.plot, SESVar%in%c("MR1_latent.raw.interquartile",
                                                      "canadaladder_pre18w","communityladder_pre18w",
                                                "dad_education_highest_num","income_pre_num","mom_education_highest_num") & Cohort=="all" & Adj.genetic==F))

ddd <- merge(ddd, data.map[,c("Vars","Label")], by.x="SESVar", by.y="Vars")
library(networkD3)
ddd <- subset(ddd, SESVar=="MR1_latent.raw.interquartile")
plot_df <- data.frame(region=ddd$Label.x, sum_length=1, Category=ddd$Category, n=ddd$UVA, mean_gain=ifelse(ddd$U=="*",0.8,0))
plot_df <- plot_df[order(plot_df$Category),]
plot_df$region <- factor(plot_df$region, levels=plot_df$region, ordered = T)

plt <- ggplot(plot_df) +
  # Make custom panel grid
  geom_hline(
    aes(yintercept = y), 
    data.frame(y = c(0:1.1)),
    color = "lightgrey"
  ) +
  geom_col(
    aes(
      x = region,
      y = 1.1,
    ),
    position = "dodge2",
    show.legend = TRUE,
  ) +
  geom_col(
    aes(
      x = region,
      y = sum_length,
      fill = n
    ),
    position = "dodge2",
    show.legend = TRUE,
  ) +
  # Add dots to represent the mean gain
  geom_point(
    aes(
      x = region,
      y = mean_gain
    ),
    size = 3,
    color = "gray12",
    pch=8
  ) +
  scale_fill_continuous_divergingx(palette = 'RdBu', mid = 0,  p1=0.5,p2=0.4,p3 = .1, p4 = .5,
                                   name="Standardized coefficient",rev = T) +
  coord_polar()+ theme(axis.text.x = element_text(angle = 
            360/(2*pi)*rev( pi/2 + seq( pi/38, 2*pi-pi/38, len=38))))
  # Make it circular!

cord.diag <- plt +
  theme(
    plot.caption = element_text(size = 1, hjust = .5),
    # Make the background white and remove extra grid lines
    panel.background = element_rect(fill = "white", color = "white"),
    panel.grid = element_blank(),
    panel.grid.major.x = element_blank()
  )
plot(cord.diag)

pdf("Figures/P2 Figure 1 correlation.pdf", width=8, height=8)
plot(cord.diag)
dev.off()
## quartz_off_screen 
##                 2

Generate sensitivity analyses of SES vs. early-life factors (Figure S1C)

#Get the order in the plot
ff.order <- c(layer_scales(ses.plot, 1, 1)$x$range$range,
              layer_scales(ses.plot, 1, 2)$x$range$range,
              layer_scales(ses.plot, 1, 3)$x$range$range,
              layer_scales(ses.plot, 1, 4)$x$range$range,
              layer_scales(ses.plot, 1, 5)$x$range$range,
              layer_scales(ses.plot, 1, 6)$x$range$range)


#Sensitivity analysis##
sub.cohort <- subset(uva.res.ses.plot, SESVar%in%"MR1_latent.raw.interquartile" & Adj.genetic==F)
sub.cohort$Var <- sub.cohort$Cohort
sub.genetic <- subset(uva.res.ses.plot, SESVar%in%"MR1_latent.raw.interquartile"  &  Cohort=="all"& Adj.genetic==T)
sub.genetic$Var <- "Adjust Genetic"
sub.ses <- subset(uva.res.ses.plot, SESVar%in%c("canadaladder_pre18w","communityladder_pre18w",
                                                "dad_education_highest_num","income_pre_num","mom_education_highest_num") &  Cohort=="all" & Adj.genetic==F)
sub.ses$Var <- sub.ses$SESVar
sub.year <- subset(uva.res.ses.plot, SESVar%in%"MR1_latent.raw.interquartile.1y"  &  Cohort=="all"& Adj.genetic==F)
sub.year$Var <- "1 year"
sens.plot <- rbind(sub.cohort, sub.ses,sub.genetic,sub.year)

data.map.ses <- data.frame(SES.Vars=c("all", "1 year","Adjust Genetic",
                                      "toronto", "vancouver", "winnipeg", "edmonton",
                                  "income_pre_num","mom_education_highest_num",  "dad_education_highest_num", 
                                  "communityladder_pre18w",    "canadaladder_pre18w"),
                           SES.Category=c("Main", "1y","Adj",
                                      "Subcohort study center","Subcohort study center","Subcohort study center","Subcohort study center",
                                      "Individual SES factor","Individual SES factor","Individual SES factor","Individual SES factor","Individual SES factor"),
                           SES.Label=c("SES index (preg.)", "SES index (1y)",
                                       "Adjust genetic ancestry",
                                   "Toronto", "Vancouver", "Winnipeg", "Edmonton",
                                   "Income","Education of mother", "Education of father",
                                   "Social status (Community)","Social status (Canada)"),
                           SES.Type=c("Continuous"),
                           SES.Values=NA)
sens.plot <- merge(sens.plot, data.map.ses, by.x="Var", by.y="SES.Vars",all.x=T)
sens.plot$SES.Label <- factor(sens.plot$SES.Label , levels=data.map.ses$SES.Label, ordered=T)
sens.plot$SES.Category <- factor(sens.plot$SES.Category, levels=unique(data.map.ses$SES.Category), ordered=T)
sens.plot$U <-  ifelse(sens.plot$UVA_P<0.05,"*","")
sens.plot$Label <- factor(sens.plot$Label, levels=ff.order, ordered=T)


sens.plot.fig <- ggplot(subset(sens.plot,  Category!="Health"), 
       aes(x=Label, y=SES.Label)) +
  geom_tile(aes(fill=UVA)) +
  geom_text(aes(label = U), color = "white", size = 5,vjust=1)+
  theme_bw() + ylab("") + xlab("") + 
  facet_grid(SES.Category ~ Category ,scales = "free",space = "free",labeller = label_wrap_gen(width=15)) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) + 
  scale_fill_continuous_divergingx(palette = 'RdBu', mid = 0,  p1=0.5,p2=0.4,p3 = .1, p4 = .5,
                                   name="Standardized coefficient",rev = T) 
sens.plot.fig

pdf("Figures/P2 SES & exposomes sensitivity.pdf", height=6.5, width=15)
plot(sens.plot.fig)
dev.off()
## quartz_off_screen 
##                 2

Generate phenotypes vs. early-life factors (Figure 1D)

#################################################################################################################
#Plot for phenotype and exposomes
#################################################################################################################
response.plot <- subset(Response.outcome, 
                        !Variables%in%c("(Intercept)", "sitetoronto", "sitevancouver", "sitewinnipeg","male1",
                                        "ethnicity_pc1","ethnicity_pc2","ethnicity_pc3") &
                          Response%in%c("Tscore_abnormal","asthma5y_ep",
                                        "overweight", "atopy5y"))
response.plot.use <- merge(subset(response.plot,Cov%in%c(used.vars,"MR1_latent.raw.interquartile")),
                          data.map.use[data.map.use$Vars%in%c(used.vars,"MR1_latent.raw.interquartile"),], 
                          by.x="Cov", by.y="Vars",all.x=T)
response.plot.use$Response[response.plot.use$Response=="asthma5y_ep"] <- "Asthma"
response.plot.use$Response[response.plot.use$Response=="overweight"] <- "Overweight/obese"
response.plot.use$Response[response.plot.use$Response=="atopy5y"] <- "Atopy"
response.plot.use$Response[response.plot.use$Response=="Tscore_abnormal"] <- "Abnormal child behavior"

response.plot.use$Category <- factor(response.plot.use$Category, 
                                     levels=c("SES","Pregnancy",
                                                                        "Birth",
                                                                        "Postnatal",
                                                                        "Home Environment",
                                                                        "Neighbourhood Environment",
                                                                        "Parental Diet/Health"),
                                     ordered=T)
response.plot.use$M <-  ifelse(response.plot.use$MVA_P<0.05,"*","")
response.plot.use$Response <- factor(response.plot.use$Response, 
                                     levels=c( "Abnormal child behavior","Atopy","Asthma", "Overweight/obese"),ordered=T)
response.plot.use$Label <- factor(response.plot.use$Label, levels=c("SES Index",ff.order), ordered=T)


response.plot.use.fig <- ggplot(subset(response.plot.use,  Category!="Health" & Cohort%in%c("all")), 
       aes(y=(Response), x=Label)) +
  geom_tile(aes(fill=MVA)) +
  geom_text(aes(label = M), color = "white", size = 4,vjust=1) +
  theme_bw() + ylab("") + xlab("") + 
  facet_grid(~Category ,scales = "free",space = "free",labeller = label_wrap_gen(width=10)) +
  scale_fill_continuous_divergingx(palette = 'RdBu', mid = 0,p1=0.5,p2=0.4, p3 =1.0, p4 =1.0,
                                   name="Standardized coefficient",rev = T) + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
response.plot.use.fig

pdf("Figures/P2 SES & exposomes & phenotype.pdf", height=4, width=15)
plot(response.plot.use.fig)
dev.off()
## quartz_off_screen 
##                 2

Generate SES index vs. phenotype (Fig 1c)

response.plot <- subset(Response.outcome, Variables=="MR1_latent.raw.interquartile" & Cohort=="all")

response.plot$ci_low <- round(exp(as.numeric(gsub("\\(","",strsplit2(response.plot$MVA_CI,",")[,1]))),2)
response.plot$ci_high <- round(exp(as.numeric(gsub("\\)","",strsplit2(response.plot$MVA_CI,",")[,2]))),2)
response.plot$MVA <- round(exp(response.plot$MVA),2)
response.plot$sig <- ifelse(response.plot$MVA_P<0.05,"sig","nosig")
response.plot$Direction <- ifelse(response.plot$MVA>0,"Positive","Negative")

response.plot <- subset(response.plot, Response%in%c("atopy5y","asthma5y_ep","overweight","Tscore_abnormal"))
response.plot$Response[response.plot$Response=="asthma5y_ep"] <- "Asthma"
response.plot$Response[response.plot$Response=="atopy5y"] <- "Atopy"

response.plot$Response[response.plot$Response=="overweight"] <- "Overweight/obese"
response.plot$Response[response.plot$Response=="Tscore_abnormal"] <- "Abnormal child behavior"
res <- response.plot[order(response.plot$Response),]
res$Response <- factor(res$Response, levels = c("Overweight/obese", "Asthma", "Atopy", "Abnormal child behavior"),
                       ordered=T)
res <- res[order(res$Response), ]

p_mid <- res |>
  ggplot(aes(y = fct_rev(Response))) + 
  theme_classic() +
  geom_point(aes(x=MVA), shape=15, size=8,col="black") +
  geom_linerange(aes(xmin=ci_low, xmax=ci_high)) +
  geom_vline(xintercept = 1, linetype="dashed") +
  labs(x="Coefficient", y="") +
  coord_cartesian(ylim=c(1,nrow(res)), xlim=c(0.5, 1.5)) +
  annotate("text", x = -1, y = 7.5, label = "Negatively associated with SES")  + 
  theme(axis.line.y = element_blank(),
        axis.ticks.y= element_blank(),
        axis.text.y= element_blank(),
        axis.title.y= element_blank())

res <- res[,c("Response","MVA","ci_low","ci_high","MVA_P","MVA_N")]
res_plot <-  res |>
  # round estimates and 95% CIs to 2 decimal places for journal specifications
  mutate(across(
    c(MVA, ci_low, ci_high),
    ~ str_pad(
      round(.x, 3),
      width = 4,
      pad = "0",
      side = "right")),
  # add an "-" between HR estimate confidence intervals
  estimate_lab = paste0(MVA, " (", ci_low, ",", ci_high, ")")) |>
  # round p-values to two decimal places, except in cases where p < .001
  mutate(MVA_P = case_when(
    MVA_P < .001 ~ "<0.001",
    round(MVA_P, 3) == .05 ~ as.character(round(MVA_P,3)),
    MVA_P < .01 ~ str_pad( # if less than .01, go one more decimal place
      as.character(round(MVA_P, 3)),
      width = 4,
      pad = "0",
      side = "right"
    ),
    TRUE ~ str_pad( # otherwise just round to 2 decimal places and pad string so that .2 reads as 0.20
      as.character(round(MVA_P, 3)),
      width = 4,
      pad = "0",
      side = "right"))) |>
  # add a row of data that are actually column names which will be shown on the plot in the next step
  bind_rows(
    data.frame(
      Response = "Phenotype",
      conf.low = "",
      conf.high = "",
      MVA_P = "p-value",
      MVA_N = "N",
      estimate_lab = "Odds Ratio (95% CI)")) |> 
  mutate(Response = fct_rev(fct_relevel(Response, "Phenotype"))) 

res_plot$Response <- factor(res_plot$Response, 
                       levels=c( 
                                 "Abnormal child behavior",  "Atopy",  "Asthma",
                                 "Overweight/obese" ),ordered=T)
res_plot <- res_plot[order(res_plot$Response),]

p_left <-
  res_plot  |>
  ggplot(aes(y = Response)) +
  geom_text(aes(x = 0, label = Response), hjust = 0, fontface = "bold") +
  geom_text(
    aes(x = 1, label = MVA_N),
    hjust = 0,
    fontface = ifelse(res_plot$MVA_N == "N", "bold", "plain")
  ) + 
  geom_text(
    aes(x = 2, label = estimate_lab),
    hjust = 0,
    fontface = ifelse(res_plot$estimate_lab == "Odds Ratio (95% CI)", "bold", "plain")
  ) +
  theme_void() +
  coord_cartesian(xlim = c(0, 4))

p_right <-
  res_plot  |>
  ggplot() +
  geom_text(
    aes(x = 0, y = Response, label = MVA_P),
    hjust = 0,
    fontface = ifelse(res_plot$MVA_P == "p-value", "bold", "plain")
  ) +
  theme_void() 

layout <- c(
  patchwork::area(t = 0, l = 0, b = 30, r = 8), 
  patchwork::area(t = 6, l = 8, b = 30, r = 18), 
  patchwork::area(t = 0, l = 18, b = 30, r = 20) 
)
# final plot arrangement
p_left + p_mid + p_right + plot_layout(design = layout)

pdf("Figures/P2 SES & Phenotype.pdf", height=6, width=12)
p_left + p_mid + p_right + plot_layout(design = layout)
dev.off()
## quartz_off_screen 
##                 2

Generate SES index + BF vs. phenotype (Fig 3C)

response.plot <- subset(Response.outcome, Cov=="SES_EBFcompound" & Cohort=="all")
response.plot$ci_low <- round(exp(as.numeric(gsub("\\(","",strsplit2(response.plot$MVA_CI,",")[,1]))),2)
response.plot$ci_high <- round(exp(as.numeric(gsub("\\)","",strsplit2(response.plot$MVA_CI,",")[,2]))),2)
response.plot$MVA <- round(exp(response.plot$MVA),2)
response.plot$sig <- ifelse(response.plot$MVA_P<0.05,"sig","nosig")
response.plot$Direction <- ifelse(response.plot$MVA>0,"Positive","Negative")

response.plot <- subset(response.plot, Response%in%c("atopy5y","asthma5y_ep","overweight","Tscore_abnormal","phenotype_atleast1"))
response.plot$Response[response.plot$Response=="phenotype_atleast1"] <- "At least one health risk"
response.plot$Response[response.plot$Response=="asthma5y_ep"] <- "Asthma"
response.plot$Response[response.plot$Response=="atopy5y"] <- "Atopy"

response.plot$Response[response.plot$Response=="overweight"] <- "Overweight/obese"
response.plot$Response[response.plot$Response=="Tscore_abnormal"] <- "Abnormal child behavior"
res <- response.plot[order(response.plot$Response),]
res$Response <- factor(res$Response, levels = c( "At least one health risk", "Overweight/obese", "Asthma", "Atopy", "Abnormal child behavior"),
                       ordered=T)
res <- res[order(res$Response), ]

res$Variables[res$Variables=="SES_EBFcompound2.Low SES w/ EBF to 6m"] <- "Low SES w/ EBF to 6m"
res$Variables[res$Variables=="SES_EBFcompound3.High SES w/o EBF to 6m"] <- "High SES w/o EBF to 6m"
res$Variables[res$Variables== "SES_EBFcompound4.High SES w/ EBF to 6m"] <- "High SES w/ EBF to 6m"

res.new <- subset(res,Variables%in%c("Low SES w/ EBF to 6m","High SES w/o EBF to 6m","High SES w/ EBF to 6m"))

res.use <- subset(res, Response== "At least one health risk" & Variables%in%c("Low SES w/ EBF to 6m","High SES w/o EBF to 6m","High SES w/ EBF to 6m"))
N.use <- with(subset(data.withmissing, !is.na(SES_EBFcompound) & !is.na(male) & !is.na(phenotype_atleast1)), table(SES_EBFcompound,phenotype_atleast1))
N.use2 <- paste(N.use[,1],N.use[,2],sep="v")
names(N.use2) <- rownames(N.use)
res.use.add <- res.use[1,]
res.use.add$MVA <- res.use.add$MVA_CI <- res.use.add$ci_high <- res.use.add$ci_low <- 1
res.use.add$Variables <- "Low SES w/o EBF to 6m"
res.use.add$MVA_P <- 1
res.use <- rbind(res.use, res.use.add)
res.use$MVA_N[res.use$Variables=="High SES w/o EBF to 6m"] <- N.use2["3.High SES w/o EBF to 6m"]
res.use$MVA_N[res.use$Variables=="High SES w/ EBF to 6m"] <- N.use2["4.High SES w/ EBF to 6m"]
res.use$MVA_N[res.use$Variables=="Low SES w/o EBF to 6m"] <- N.use2["1.Low SES w/o EBF to 6m"]
res.use$MVA_N[res.use$Variables=="Low SES w/ EBF to 6m"] <- N.use2["2.Low SES w/ EBF to 6m"]


res.use$Variables <-  factor(res.use$Variables, 
                       levels=c("Low SES w/o EBF to 6m"  ,
                                 "Low SES w/ EBF to 6m" ,
                       
                                 "High SES w/o EBF to 6m",
                                "High SES w/ EBF to 6m"
                                 
                                    ),ordered=T)
res.use <- res.use[order(res.use$Variables),]
p_mid <- res.use |>
  ggplot(aes(y = fct_rev(Variables))) + 
  theme_classic() +
  geom_point(aes(x=MVA), shape=15, size=8,col="black") +
  geom_linerange(aes(xmin=ci_low, xmax=ci_high)) +
  geom_vline(xintercept = 1, linetype="dashed") +
  labs(x="Coefficient", y="") +
  coord_cartesian( xlim=c(0.25, 1.25)) +
  theme(axis.line.y = element_blank(),
        axis.ticks.y= element_blank(),
        axis.text.y= element_blank(),
        axis.title.y= element_blank())

res_plot <-  res.use |>
  # round estimates and 95% CIs to 2 decimal places for journal specifications
  mutate(across(
    c(MVA, ci_low, ci_high),
    ~ str_pad(
      round(.x, 3),
      width = 4,
      pad = "0",
      side = "right")),
  # add an "-" between HR estimate confidence intervals
  estimate_lab = paste0(MVA, " (", ci_low, ",", ci_high, ")")) |>
  # round p-values to two decimal places, except in cases where p < .001
  mutate(MVA_P = case_when(
    MVA_P < .001 ~ "<0.001",
    round(MVA_P, 3) == .05 ~ as.character(round(MVA_P,3)),
    MVA_P < .01 ~ str_pad( # if less than .01, go one more decimal place
      as.character(round(MVA_P, 3)),
      width = 4,
      pad = "0",
      side = "right"
    ),
    TRUE ~ str_pad( # otherwise just round to 2 decimal places and pad string so that .2 reads as 0.20
      as.character(round(MVA_P, 3)),
      width = 4,
      pad = "0",
      side = "right"))) |>
  # add a row of data that are actually column names which will be shown on the plot in the next step
  bind_rows(
    data.frame(
      Response = "Phenotype",
      conf.low = "",
      conf.high = "",
      MVA_P = "p-value",
      MVA_N = "N",
      estimate_lab = "Odds Ratio (95% CI)")) |> 
  mutate(Response = fct_rev(fct_relevel(Response, "Phenotype"))) 

res_plot$Variables <- factor(res_plot$Variables, 
                       levels=c("High SES w/ EBF to 6m",
                                 "High SES w/o EBF to 6m",
                       
                                  "Low SES w/ EBF to 6m" ,
                                    "Low SES w/o EBF to 6m"  ),ordered=T)
res_plot <- res_plot[order(res_plot$Variables),]
res_plot$estimate_lab[res_plot$estimate_lab=="1 (1,1)"] <- "Ref"
p_left <-
  res_plot  |>
  ggplot(aes(y = Variables)) +
  geom_text(aes(x = 0, label = Variables), hjust = 0, fontface = "bold") +
  geom_text(
    aes(x = 1, label = MVA_N),
    hjust = 0,
    fontface = ifelse(res_plot$MVA_N == "N", "bold", "plain")
  ) + 
  geom_text(
    aes(x = 2, label = estimate_lab),
    hjust = 0,
    fontface = ifelse(res_plot$estimate_lab == "Odds Ratio (95% CI)", "bold", "plain")
  ) +
  theme_void() +
  coord_cartesian(xlim = c(0, 4))

p_right <-
  res_plot  |>
  ggplot() +
  geom_text(
    aes(x = 0, y = Variables, label = MVA_P),
    hjust = 0,
    fontface = ifelse(res_plot$MVA_P == "p-value", "bold", "plain")
  ) +
  theme_void() 

layout <- c(
  patchwork::area(t = 0, l = 0, b = 30, r = 8), 
  patchwork::area(t = 6, l = 8, b = 30, r = 18), 
  patchwork::area(t = 0, l = 18, b = 30, r = 20) 
)
# final plot arrangement
p_left + p_mid + p_right + plot_layout(design = layout)

pdf("Figures/P2 SESBF & Phenotype.pdf", height=6, width=12)
p_left + p_mid + p_right + plot_layout(design = layout)
dev.off()
## quartz_off_screen 
##                 2

Run PERMANOVA analysis (Figure 2, 3)

rm(list=ls())
library(phyloseq)
library(psych)
library(corrplot)
library("psych")
library(ggplot2)
library(car)
library(magrittr)
library(ggcorrplot)
library(missForest)
library(xlsx)
library(ggpubr)
library(lavaan)
library(limma)
library(metaMint)
library(lubridate)
library(plyr)
library(stringr)
library(dplyr)
library(cowplot)
library(ggrepel)
library(ecodist)
library(reshape2)
# work.dir <- "~/Documents/SES_Manuscript/"
work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"

setwd(work.dir)
load("Results/P1 Processed Metagenomic data.RData")

#No need to run again
cov.vars <- c("MR1_latent.raw", "atbx.microbiome.new", "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
              "awayhome1h_3m", "bf","bw_sd", "canue_Zdweldensity_pre18w" ,
              "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
              "dog_1y", "fasthma","father_atopy_1y",
              "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
              "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
              "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
              "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
              "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter")#"male",
# 
# 
# No need to run again
# ############################################################################################################
# library(vegan)
# technical.vars <- c("ProcessingPeriod" ,"exact_age")
# 
# PERMANOVA.UVA <- NULL
# visit.all <- c("1 year","3 month")
# vars.use <- cov.vars
# cohort <- "all"
# for(data.type in c("Species")){
#   if(data.type=="Species"){
#     OTU.use <- RBNME_species_MCLR
#   }
# 
#   for(visit in visit.all){
#     if(visit%in%c("3 month", "1 year")){
#       s.use <- as.character(data.div$SampleID[data.div$Visit==visit])
#       s.use.subjectid <- as.character(data.div$SubjectNumber[data.div$Visit==visit])
#     }
#     for(missing in c("raw")){
#       if(missing=="raw"){data.cli.p <- data.withmissing[data.withmissing$subjectnumber%in%s.use.subjectid,]}
#       data.cli.p <- merge(data.cli.p, data.div[s.use,c("SubjectNumber","SampleID","Visit","exact_age","ProcessingPeriod")],
#                           by.x="subjectnumber", by.y="SubjectNumber")
#       # data.cli.p <- data.cli.p[!is.na(data.cli.p$MR1_latent.raw),]
#       data.cli.p$atbx.microbiome.new <- ifelse(data.cli.p$Visit=="3 month", as.numeric(as.character(data.cli.p$atbx.micro3m)), as.numeric(as.character(data.cli.p$atbx.micro1y)))
#       data.cli.p$bf <- ifelse(data.cli.p$exact_age*12<data.cli.p$bf_duration_imp,1, 0)
#       if(visit%in%c("3 month", "1 year")){
#         rownames(data.cli.p) <- data.cli.p$subjectnumber
#       }
# 
#       s.overlap <- data.cli.p$subjectnumber
#       s.overlap <- as.character(s.overlap)
#       otu.table.use <- data.frame(otu_table(OTU.use))
#       #  otu.table.use[otu.table.use==0] <- min(otu.table.use[otu.table.use>0])/2
#       # otu.table.use <- log(otu.table.use)
#       otu.table.sub <- otu.table.use[s.use,]
#       rownames(otu.table.sub) <- s.use.subjectid
# 
#       for(var.use in vars.use){
# 
#         var.model.use <- c("ProcessingPeriod" ,"exact_age", var.use)
# 
#         full.model <- paste("otu.table.model ~ ", paste(var.model.use, collapse = "+"))
#         data.cli.p.nomissing <- na.omit(data.cli.p[,c(var.model.use,"site")])
# 
#         s.nomissing <- as.character(rownames(data.cli.p.nomissing))
#         data.cli.model <- data.cli.p[s.nomissing,]
#         otu.table.model <- otu.table.sub[s.nomissing,]
#         set.seed(343834)
#         margin.permanova <- adonis2(as.formula(full.model),
#                                     data = data.cli.p.nomissing,
#                                     permutations = 999,
#                                     method="euclidean",
#                                     by="margin",
#                                     strata =data.cli.p.nomissing$site)
# 
#         res.margin <- data.frame(Data=data.type,
#                                  Imputation=missing,
#                                  Visit=visit,
#                                  Cohort=cohort,
#                                  Var=c(var.model.use,"Residual","Total"),
#                                  N=length(s.nomissing),
#                                  Tes=var.use,
#                                  R2.margin=margin.permanova$R2,
#                                  Fvalue.margin=margin.permanova$F,
#                                  p.margin=margin.permanova$`Pr(>F)`)
# 
#         res <- res.margin
# 
#         PERMANOVA.UVA <- rbind(PERMANOVA.UVA, res)
#         save(PERMANOVA.UVA, file="Results/P3 UVA PERMANOVA Res.RData")
#       }
#     }
#   }
# }
# 
# varespec.bray.all <- NULL
# visit.all <- c("1 year","3 month")
# i <- 1
# for(data.type in c("Species" )){
#   if(data.type=="Species"){
#     OTU.use <- RBNME_species_MCLR
#   }
#   if(data.type=="META"){
#     OTU.use <- RBMETA
#   }
#   for(visit in visit.all){
#     if(visit%in%c("3 month", "1 year")){
#       s.use <- as.character(data.div$SampleID[data.div$Visit==visit])
#       s.use.subjectid <- as.character(data.div$SubjectNumber[data.div$Visit==visit])
#     }
#     for(missing in c("raw")){
#       if(missing=="raw"){data.cli.p <- data.withmissing[data.withmissing$subjectnumber%in%s.use.subjectid,]}
#       data.cli.p <- merge(data.cli.p, data.div[s.use,c("SubjectNumber","SampleID","exact_age","ProcessingPeriod")],
#                           by.x="subjectnumber", by.y="SubjectNumber")
#       data.cli.p <- subset(data.cli.p, exact_age<1.5)
#       if(visit%in%c("3 month", "1 year")){
#         rownames(data.cli.p) <- data.cli.p$subjectnumber
#       }
# 
#       s.overlap <- data.cli.p$subjectnumber
#       s.overlap <- as.character(s.overlap)
#       otu.table.use <- data.frame(otu_table(OTU.use))
#       # otu.table.use[otu.table.use==0] <- min(otu.table.use[otu.table.use>0])/2
#       # otu.table.use <- log(otu.table.use)
#       otu.table.sub <- otu.table.use[s.use,]
#       rownames(otu.table.sub) <- s.use.subjectid
#       vars.use <- "MR1_latent.raw"
#       full.model <- paste("otu.table.model ~ ", paste(vars.use, collapse = "+"))
#       data.cli.p.nomissing <- na.omit(data.cli.p[,vars.use,drop=F])
# 
#       s.nomissing <- as.character(rownames(data.cli.p.nomissing))
#       data.cli.model <- data.cli.p[s.nomissing,]
#       otu.table.model <- otu.table.sub[rownames(data.cli.model),]
# 
#       set.seed(343834)
#       varespec.bray <- vegan::vegdist(otu.table.model, method = "euclidean") # dissimilarity matrix using bray-curtis distance indices on the varespec dataset native to vegan
#       varespec.bray.all[[i]] <- list(varespec.bray,data.cli.model)
#       names(varespec.bray.all)[i] <- paste(visit,data.type,sep="_")
#       i <- i +1
# 
#     }
#   }
# }
# 
# 
# library(ecodist)
# 
# pcoaVS.sp.3m <- ecodist::pco(varespec.bray.all$`3 month_Species`[[1]], negvals = "zero", dround = 0)
# pcoaVS.sp.1y <- ecodist::pco(varespec.bray.all$`1 year_Species`[[1]], negvals = "zero", dround = 0)
# 
# 
# pcoaVS.sp.3m$values[1]/sum(pcoaVS.sp.3m$values)
# pcoaVS.sp.3m$values[2]/sum(pcoaVS.sp.3m$values)
# 
# pcoaVS.sp.1y$values[1]/sum(pcoaVS.sp.1y$values)
# pcoaVS.sp.1y$values[2]/sum(pcoaVS.sp.1y$values)
# 
# summary(pcoaVS.sp.3m)
# data1 <- data.frame(subjectnumber=rownames(varespec.bray.all$`3 month_Species`[[2]]),
#                     sp.3m.PCoA1=scale(pcoaVS.sp.3m$vectors[,1]),
#                     sp.3m.PCoA2=scale(pcoaVS.sp.3m$vectors[,2]))
# data2 <- data.frame(subjectnumber=rownames(varespec.bray.all$`1 year_Species`[[2]]),
#                     sp.1y.PCoA1=scale(pcoaVS.sp.1y$vectors[,1]),
#                     sp.1y.PCoA2=scale(pcoaVS.sp.1y$vectors[,2]))
# 
# data.pcoa <- merge(data1, data2,by="subjectnumber",all=T)
# save(data.pcoa,varespec.bray.all, file= "Results/P3 PCOA data.RData")
 
load("Results/P3 UVA PERMANOVA Res.RData")
load("Results/P3 PCOA data.RData")
load("Results/P5 Maaslin2 Results.RData")

Create alpha diversity across SES (Figure 2A,B, Figure S2A,B)

###############################################
data.raw <- data.withmissing
data.div.3m <- subset(data.div, Visit=="3 month")
data.div.1y <- subset(data.div, Visit=="1 year")
data.div.all <- merge(data.div.3m, data.div.1y, by="SubjectNumber",all=T, suffixes = c(".3m",".1y"))
data.div.all$Shannon.x.change <- data.div.all$Shannon.x.1y-data.div.all$Shannon.x.3m
data.div.all <- merge(data.raw, data.div.all,by.x="subjectnumber", by.y="SubjectNumber")

data.div.all$bf.3m <- ifelse(data.div.all$exact_age.3m*12<data.div.all$bf_duration_imp,1, 0)
data.div.all$bf.1y <- ifelse(data.div.all$exact_age.1y*12<data.div.all$bf_duration_imp,1, 0)
data.div.all$bf_status.3m <- ifelse(data.div.all$exact_age.3m*12<data.div.all$ebf_duration,"EBF", 
                                    ifelse(data.div.all$exact_age.3m*12<data.div.all$bf_duration_imp,"BF","No BF"))

data.div.all$bf_status.1y <- ifelse(data.div.all$exact_age.1y*12<data.div.all$ebf_duration,"EBF", 
                                    ifelse(data.div.all$exact_age.1y*12<data.div.all$bf_duration_imp,"BF","No BF"))

data.div.all$cat_SES <- ifelse(data.div.all$cat_SES=="1.0-25%", "SES Q1",
                               ifelse(data.div.all$cat_SES=="2.25-50%", "SES Q2",
                                      ifelse(data.div.all$cat_SES=="3.50-75%", "SES Q3","SES Q4")))

my_comparisons.use <- list(c("SES Q1","SES Q2"),c("SES Q1","SES Q3"),c("SES Q1","SES Q4"))
ses.vars.use <- c("used.vatSES Q2", "used.vatSES Q3","used.vatSES Q4")
plot.var.use <- "cat_SES"
sig.var.use <- "SES Q2"
sig.var.new.use <- "SES Q1"
var.order.use <- c( "SES Q1", "SES Q2",  "SES Q3", "SES Q4")
plot.var=plot.var.use
ses.vars=ses.vars.use
my_comparisons=my_comparisons.use 
sig.var=sig.var.use
sig.var.new=sig.var.new.use
var.order=var.order.use

data.div.all$used.vat <- data.div.all[,plot.var]
data.3m <- melt(with(subset(data.div.all,!is.na(used.vat) & !is.na(bf_status.3m)),
                     table(used.vat, bf_status.3m)))

data.3m$bf_status.3m <- factor(data.3m$bf_status.3m, levels=c("EBF","BF","No BF"))
data.3m$used.vat <- factor(data.3m$used.vat, levels=var.order,ordered=T)

# Stacked + percent 
library(scales)
p1.3m <- ggplot(data.3m, aes(fill=bf_status.3m, y=value, x=used.vat)) + 
  geom_bar(position="fill", stat="identity") +
  scale_fill_manual(values = c("#c3423f" ,"#f0a390" , "#f7d0c6")) +
  theme_bw()+ theme(legend.position = "none") +
  geom_text(aes(label = percent(..y../tapply(..y..,..x..,sum)[..x..],accuracy=1)),
            stat = "identity",position = position_fill(vjust=0.5), color="white")

data.1y <- melt(with(subset(data.div.all,!is.na(used.vat) & !is.na(bf_status.1y)),
                     table(used.vat, bf_status.1y)))
data.1y$bf_status.1y <- factor(data.1y$bf_status.1y, levels=c(  "EBF","BF","No BF"))
data.1y$used.vat <- factor(data.1y$used.vat, levels=var.order,ordered=T)

p1.1y <- ggplot(data.1y, aes(fill=bf_status.1y, y=value, x=used.vat)) + 
  geom_bar(position="fill", stat="identity") +
  scale_fill_manual(values = c("#f0a390" , "#f7d0c6")) +
  theme_bw()+ theme(legend.position = "none") +
  geom_text(aes(label = percent(..y../tapply(..y..,..x..,sum)[..x..],accuracy=1)),
            stat = "identity",position = position_fill(vjust=0.5), color="white")


dat1 <- data.div.all[,c("subjectnumber","used.vat","Shannon.x.3m")]
dat1$Visit <- "3 month"
dat2 <- data.div.all[,c("subjectnumber","used.vat","Shannon.x.1y")]
dat2$Visit <- "1 year"
dat3 <- data.div.all[,c("subjectnumber","used.vat","Shannon.x.change")]
dat3$Visit <- "Change"
colnames(dat1) <-  colnames(dat2) <- colnames(dat3) <-c("subjectnumber","used.vat","Shannon","Visit")
dat.all <- rbind(dat1, dat2, dat3)
dat.all$used.vat <- factor(dat.all$used.vat, levels=var.order,ordered=T)
dat.all$Visit <- factor(dat.all$Visit, levels=c("3 month", "1 year", "Change"))
SES.masslin.use <- subset(SES.maaslin,   
                          BFsub=="All" & Race.Adj=="none" & check.var=="MR1_latent.raw" &feature=="Shannon.x" &
                            Normalization=="raw" & adjbasic== "ProcessingPeriod + exact_age"&
                            ((Visit%in%c("3 month","1 year") &  value%in%c("MR1_latent.raw")) | 
                               (Visit %in%c("longitudinal") &value%in%c("time_interaction"))) & 
                            Data=="DIV" & Prevalence_cutoff==0.1)

add.masslin.res <- data.frame(Visit=c("3 month","1 year", "Change"),
                              pval=signif(SES.masslin.use$pval,digits = 2))
add.masslin.res$Visit <- factor(add.masslin.res$Visit, levels=c("3 month", "1 year", "Change"))

p2.all <- ggplot(subset(dat.all,!is.na(used.vat)), aes(x=used.vat, y=Shannon, fill=used.vat)) + 
  geom_boxplot() +
  scale_fill_manual(values = c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  stat_compare_means(comparisons = my_comparisons,label="p.signif", vjust = 0.5,
                     step.increase = 0.03, tip.length = 0.01) +
  facet_wrap(~Visit,scale="free_y") +
  theme_bw() +
  ylab("Species alpha diversity (Shannon)") + 
  xlab("SES Latent Factor") + theme(legend.position = "none") +
  geom_text(data=add.masslin.res, aes(x = 2, y = 0, label = pval),
            parse = TRUE, inherit.aes=FALSE) 
plot(p2.all)

p2.3m <- ggplot(subset(data.div.all,!is.na(used.vat)), aes(used.vat, Shannon.x.3m, fill=used.vat)) + 
  geom_boxplot() +
  theme_bw() +
  scale_fill_manual(values = c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  ylab("Species alpha diversity (Shannon)") + 
  stat_compare_means(comparisons = my_comparisons,label="p.signif",vjust = 0.8,
                     step.increase = 0.03, tip.length = 0.01) +
  xlab("SES Latent Factor") + theme(legend.position = "none")


p2.1y <- ggplot(subset(data.div.all,!is.na(used.vat)), aes(used.vat, Shannon.x.1y, fill=used.vat)) + 
  geom_boxplot() +
  scale_fill_manual(values = c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  theme_bw() +
  ylab("Species alpha diversity (Shannon)") + 
  stat_compare_means(comparisons = my_comparisons,label = "p.signif",vjust = 0.5,
                     step.increase = 0.03, tip.length = 0.01) +
  xlab("SES Latent Factor") + theme(legend.position = "none")


data.div.all$used.vat <- relevel(factor(data.div.all$used.vat,ordered=F), ref=sig.var.new)

res1.3m <- UVAMVA.func(subset(data.div.all),
                       res.va="Shannon.x.3m",
                       conf.vars.func=unique(c("used.vat","ProcessingPeriod.3m","exact_age.3m")),
                       func.type="lmer", strata="site",
                       ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
res1.3m$Visit <- "3 month"
res1.3m$bf <- "Not adjust for bf"
res1.1y <- UVAMVA.func(subset(data.div.all),
                       res.va="Shannon.x.1y",
                       conf.vars.func=unique(c("used.vat","ProcessingPeriod.1y","exact_age.1y")),
                       func.type="lmer", strata="site",
                       ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
res1.1y$Visit <- "1 year"
res1.1y$bf <- "Not adjust for bf"
res2.3m <- UVAMVA.func(subset(data.div.all),
                       res.va="Shannon.x.3m",
                       conf.vars.func=unique(c("used.vat","ProcessingPeriod.3m","exact_age.3m","bf_status.3m")),
                       func.type="lmer", strata="site",
                       ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")

res2.3m$Visit <- "3 month"
res2.3m$bf <- "Adjust for bf"
res2.1y <- UVAMVA.func(subset(data.div.all),
                       res.va="Shannon.x.1y",
                       conf.vars.func=unique(c("used.vat","ProcessingPeriod.1y","exact_age.1y","bf_status.1y")),
                       func.type="lmer", strata="site",
                       ana.type="MVA", ci=T, save.model=F, na.uva="Each",scale="log")
res2.1y$Visit <- "1 year"
res2.1y$bf <- "Adjust for bf"
shannon.ses <- rbind(res1.3m[ses.vars,],res1.1y[ses.vars,],
                     res2.3m[ses.vars,],res2.1y[ses.vars,])

shannon.ses$ci_low <- as.numeric(gsub("\\(","",strsplit2(shannon.ses$MVA_CI,",")[,1]))
shannon.ses$ci_high <- as.numeric(gsub("\\)","",strsplit2(shannon.ses$MVA_CI,",")[,2]))
shannon.ses$sig <- ifelse(shannon.ses$MVA_P<0.05,"sig","nosig")
shannon.ses$bf <- factor(shannon.ses$bf, levels=c("Not adjust for bf","Adjust for bf"),
                         ordered=T)
shannon.ses$Variables <- gsub("used.vat","",shannon.ses$Variables)
addQ1 <- subset(shannon.ses,Variables==sig.var)
addQ1$MVA <- 0
addQ1$ci_high <- 0
addQ1$ci_low <- 0
addQ1$sig <- "sig"
addQ1$Variables <- gsub(sig.var,sig.var.new,addQ1$Variables)
shannon.ses <- rbind(shannon.ses, addQ1)
shannon.ses$Variables <- factor(shannon.ses$Variables, levels=var.order, ordered=T)
p3.3m <- ggplot(subset(shannon.ses, Visit=="3 month"),
                aes(y=MVA, x=Variables,fill = bf)) + 
  theme_bw() + 
  xlab("Coefficient") +
  geom_errorbar(aes(ymin=ci_low,ymax=ci_high), width=.2, position=position_dodge(0.5)) +
  geom_point(position=position_dodge(0.5), size = 3, pch = 21) +
  ylab("") + ggtitle("") +
  xlab("Coefficient") +
  scale_shape_manual(values=seq(0,10)) +
  scale_color_manual(values = c('gray', 'black'))+
  scale_fill_manual(values = c( 
    "#e76f51" ,"#f7d0c6" )) +
  geom_hline(yintercept = 0) +  theme(legend.position = "none")

p3.1y <- ggplot(subset(shannon.ses, Visit=="1 year"),
                aes(y=MVA, x=Variables,fill = bf)) + 
  theme_bw() + 
  xlab("Coefficient") +
  geom_errorbar(aes(ymin=ci_low,ymax=ci_high), width=.2, position=position_dodge(0.5)) +
  geom_point(position=position_dodge(0.5), size = 3, pch = 21) +
  ylab("") + ggtitle("") +
  xlab("Coefficient") +
  scale_shape_manual(values=seq(0,10)) +
  scale_color_manual(values = c('gray', 'black'))+
  scale_fill_manual(values = c( 
    "#e76f51" ,  "#f7d0c6"  ))+
  geom_hline(yintercept = 0) + theme(legend.position = "none")


plot1.3m <- insert_xaxis_grob(p2.3m, p3.3m, grid::unit(.2, "null"), position = "top")
plot2.3m <- insert_yaxis_grob(plot1.3m, p1.3m, grid::unit(.3, "null"), position = "right")


plot1.1y <- insert_xaxis_grob(p2.1y, p3.1y, grid::unit(.2, "null"), position = "top")
plot2.1y <- insert_yaxis_grob(plot1.1y, p1.1y, grid::unit(.3, "null"), position = "right")

ggarrange(plot2.3m, plot2.1y)

pdf("Figures/P6 Diviersity and SES errorbar more.pdf",height=6,width=8)
plot(p2.all)
ggarrange(plot2.3m, plot2.1y)
dev.off()
## quartz_off_screen 
##                 2

Create PERMANOVA analysis results (Figure 2C)

data.map.use <- data.map
PERMANOVA.all <- subset(PERMANOVA.UVA, Var%in%cov.vars[!cov.vars%in%"EBF_6m"])
PERMANOVA.all[PERMANOVA.all$Var== "no2.y1" & PERMANOVA.all$Visit=="3 month","R2.margin"] <- 0
PERMANOVA.all[PERMANOVA.all$Var== "no2.y1" & PERMANOVA.all$Visit=="3 month","p.margin"] <- 1
PERMANOVA.all[PERMANOVA.all$Var== "no2.y1" & PERMANOVA.all$Visit=="3 month","Fvalue.margin"] <- NA

PERMANOVA.all.plot <- merge(PERMANOVA.all,data.map.use ,by.x="Var", by.y="Vars",all.x=T)
PERMANOVA.all.plot$Visit <- factor(PERMANOVA.all.plot$Visit, levels=c("3 month", "1 year"), ordered=T)
PERMANOVA.all.plot$U <- ifelse(PERMANOVA.all.plot$p.margin<0.05, "+","")
PERMANOVA.all.plot$Data <- factor(PERMANOVA.all.plot$Data, levels=c( "Species","META"), ordered=T)
dd <- unique(subset(PERMANOVA.all.plot))

rank.dd <- plyr::ddply(dd, .(Label), summarise, mean.r2=mean(R2.margin))
rank.dd <- rank.dd[order(rank.dd$mean.r2,decreasing = F),]
dd$Label <- factor(dd$Label, levels=unique(rank.dd$Label), ordered=T)
dd$Significance <- ifelse(dd$p.margin<0.05,"p<0.05","Not significant")
dd$R2.margin <- dd$R2.margin*100
dd$Category <- factor(dd$Category, levels=c("SES","Pregnancy","Birth",
                                                                        "Postnatal",
                                                                        "Home Environment",
                                                                        "Neighbourhood Environment",
                                                                        "Parental Diet/Health"), ordered=T)

dd.3m <- subset(dd, Visit=="3 month")
# dd.3m[order(dd.3m$R2.margin, decreasing=T),]

dd.1y <- subset(dd, Visit=="1 year")
# dd.1y[order(dd.1y$R2.margin, decreasing=T),]

dd.sig <- subset(dd, Cohort=="all")#Var %in% subset(dd,Significance=="p<0.05")$Var & 
dd.sig <- subset(dd.sig, !Var%in%c("ethnicity_pc1","ethnicity_pc2","ethnicity_pc3"))
dd.sig <- dd.sig[order(dd.sig$Category, decreasing = T),]
dd.sig.3m <- subset(dd.sig, Visit=="3 month" & !Label%in%c("Air pollution (NO2) (1y)","Reg. childcare attend. (1y)","Maternal distress (1y)"))
dd.sig.3m <- dd.sig.3m[order(dd.sig.3m$R2.margin,decreasing=T),]
dd.sig.1y <- subset(dd.sig, Visit=="1 year")
dd.sig.1y <- dd.sig.1y[order(dd.sig.1y$R2.margin,decreasing=T),]
dd.sig <- rbind(dd.sig.3m,dd.sig.1y)
dd.sig <- dd.sig[order(dd.sig$R2.margin,decreasing=T),]
dd.sig$Label <- factor(dd.sig$Label, levels=rev(unique(c(dd.sig.3m$Label,dd.sig.1y$Label))),ordered=T)
dd.sig$Rank <- NA
dd.sig[dd.sig$Cohort=="all" & dd.sig$Visit=="3 month" & dd.sig$p.margin < 0.05,"Rank"][1:10] <- 1:10
dd.sig[dd.sig$Cohort=="all" & dd.sig$Visit=="1 year" & dd.sig$p.margin < 0.05,"Rank"][1:10] <- 1:10


subset(dd.sig, Visit=="3 month" & Cohort=="all")[,c("Var","R2.margin","p.margin")]
##                                               Var  R2.margin p.margin
## 11                                             bf 1.69667145    0.001
## 73                                        vaginal 0.73184450    0.001
## 61                                   num_siblings 0.68594803    0.001
## 56                                 MR1_latent.raw 0.67635765    0.001
## 47                                   mom_bmi_best 0.46129220    0.001
## 63                                postnatal_smoke 0.42890263    0.001
## 1                                    atbx.m.birth 0.34880811    0.001
## 68                                 prenatal_smoke 0.32506315    0.001
## 58                                       no2.preg 0.30075755    0.001
## 16                      canue_Zdweldensity_pre18w 0.28893068    0.001
## 31                               freq_score_basic 0.25576959    0.001
## 13                                          bw_sd 0.20672382    0.001
## 21                                         dog_1y 0.17226327    0.006
## 65                             Pregnancy.Tdens250 0.16261359    0.111
## 49                                   mom_UPFContr 0.16048782    0.003
## 35                                      gest_days 0.14402386    0.002
## 17                                         cat_1y 0.13754602    0.012
## 28                                father_atopy_1y 0.12752391    0.063
## 51                                mother_atopy_1y 0.12131095    0.021
## 39                                    hometype_3m 0.12043892    0.501
## 37                                  home_plant_3m 0.12034108    0.032
## 23                                           fall 0.11953464    0.008
## 33                    furniture_densityclutter_3m 0.11245649    0.053
## 19 condition_GestationalDiabetes_mother_prelabour 0.11175464    0.021
## 3                                     atbx.m.preg 0.10356430    0.041
## 9                                   awayhome1h_3m 0.08871805    0.170
## 54                                    mould_3m_mh 0.08568846    0.223
## 30                                floor_carpet_3m 0.08425865    0.350
## 5                             atbx.microbiome.new 0.08344628    0.235
## 69                                          rural 0.08133365    0.501
## 76                                         winter 0.08107187    0.236
## 71                                         summer 0.06763193    0.513
## 46              maternaldistress_perceived_pre18w 0.06761777    0.620
## 42                                        masthma 0.05790631    0.739
## 25                                        fasthma 0.05202715    0.928
subset(dd.sig, Visit=="1 year" & Cohort=="all")[,c("Var","R2.margin","p.margin")]
##                                               Var  R2.margin p.margin
## 12                                             bf 1.27173416    0.001
## 62                                   num_siblings 1.14646132    0.001
## 15                      canue_Zdweldensity_pre18w 0.51163605    0.001
## 57                                       no2.preg 0.41038032    0.001
## 60                                         no2.y1 0.38115426    0.001
## 55                                 MR1_latent.raw 0.31312209    0.002
## 74                                        vaginal 0.28334442    0.001
## 32                               freq_score_basic 0.27319909    0.001
## 6                             atbx.microbiome.new 0.22865296    0.001
## 40                                    hometype_3m 0.21794623    0.067
## 66                             Pregnancy.Tdens250 0.21431368    0.015
## 2                                    atbx.m.birth 0.20667344    0.004
## 48                                   mom_bmi_best 0.19855170    0.002
## 14                                          bw_sd 0.18954784    0.001
## 50                                   mom_UPFContr 0.17377371    0.004
## 70                                          rural 0.17362647    0.021
## 64                                postnatal_smoke 0.16140642    0.021
## 38                                  home_plant_3m 0.13514464    0.031
## 22                                         dog_1y 0.12203312    0.119
## 7                                   awayhome1h_1y 0.12116461    0.043
## 67                                 prenatal_smoke 0.12008531    0.083
## 29                                floor_carpet_3m 0.11937341    0.078
## 53                                    mould_3m_mh 0.10722979    0.062
## 52                                mother_atopy_1y 0.10684928    0.104
## 18                                         cat_1y 0.10628562    0.090
## 36                                      gest_days 0.09646927    0.088
## 34                    furniture_densityclutter_3m 0.09152818    0.164
## 26                                        fasthma 0.08691249    0.287
## 45              maternaldistress_perceived_pre18w 0.08602126    0.267
## 27                                father_atopy_1y 0.08235287    0.564
## 4                                     atbx.m.preg 0.08137320    0.212
## 43                  maternaldistress_perceived_1y 0.07959277    0.373
## 41                                        masthma 0.07491016    0.336
## 75                                         winter 0.05812149    0.721
## 10                                  awayhome1h_3m 0.05761239    0.763
## 24                                           fall 0.05558092    0.794
## 72                                         summer 0.05543002    0.799
## 20 condition_GestationalDiabetes_mother_prelabour 0.04962701    0.877
permanova.plot <- ggplot(subset(dd.sig,Cohort=="all"), 
       aes(x=R2.margin, y=Label,fill=Category, 
                                         color=Category, alpha = U))+
  geom_bar(stat="identity") +
  geom_text(aes(x=0.04,label = Rank),color="white", vjust = 0.7,fontface = "bold")+
  theme_bw() +
  facet_grid(~Visit, scales = "free_x", labeller = label_wrap_gen(12)) +
  xlab("Beta-diversity variance explained (R2) %") + ylab("") + 
  scale_fill_manual(values=c( "#8ab17d", "#e9c46a","#f4a261", "#e76f51", "#2a9d8f", "#287271", "#9A4770"))+
  scale_color_manual(values=c( "#8ab17d", "#e9c46a","#f4a261", "#e76f51", "#2a9d8f", "#287271", "#9A4770"))
plot(permanova.plot)

pdf("Figures/P3 UVA PERMANOVA barplot.pdf", height=8, width=12)
plot(permanova.plot)
dev.off()
## quartz_off_screen 
##                 2

Generate PCoA figure (Figure 2D)

pcoa.plot <- vector("list")
pco.i <- 1
data.alpha.all.both <- NULL
visit <- "1 year"
visit <- "3 month"
for(visit in c("1 year", "3 month")){
  sig.use <- "top5"
  
  if(sig.use=="top5"){
    if(visit=="3 month"){
      used.pco.vars <- unique(c(unique(c(dd.sig.3m$Var[1:10]))))
      
    }
   
    if(visit=="1 year"){
      used.pco.vars <- unique(c(unique(c(dd.sig.1y$Var[1:10]))))
      
    }
    varespec.bray.use <- varespec.bray.all
  }

  if(visit=="3 month"){
    pcoaVS <- ecodist::pco(varespec.bray.use$`3 month_Species`[[1]], negvals = "zero", dround = 0)
    data.alpha.all <- varespec.bray.use$`3 month_Species`[[2]]
    data.alpha.all$Visit <- "3 month"
  }
  if(visit=="1 year"){
    pcoaVS <- ecodist::pco(varespec.bray.use$`1 year_Species`[[1]], negvals = "zero", dround = 0) 
    data.alpha.all <- varespec.bray.use$`1 year_Species`[[2]]
    data.alpha.all$Visit <- "1 year"
  }
  data.alpha.all$PCoA1 <- pcoaVS$vectors[,1]
  data.alpha.all$PCoA2 <- pcoaVS$vectors[,2]
  data.alpha.all$PCoA3 <- pcoaVS$vectors[,3]
  data.alpha.all$PCoA4 <- pcoaVS$vectors[,4]
  
  data.alpha.all$atbx.microbiome <- ifelse(data.alpha.all$atbx.1y.time<data.alpha.all$exact_age*365,1,0)
  data.alpha.all$atbx.microbiome.new <- ifelse(data.alpha.all$Visit=="3 month", as.numeric(as.character(data.alpha.all$atbx.micro3m)),
                                                     as.numeric(as.character(data.alpha.all$atbx.micro1y)))
  
  data.alpha.all$bf <- ifelse(data.alpha.all$exact_age*12<data.alpha.all$bf_duration_imp,1, 0)
  if(any(!used.pco.vars%in%colnames(data.alpha.all))){
    data.alpha.all <- merge(data.alpha.all, data.withmissing[,c("subjectnumber",used.pco.vars[!used.pco.vars%in%colnames(data.alpha.all)])],by="subjectnumber",all.x=T)
  }

  arrows <- NULL
  for(permanova.var in c(used.pco.vars)){
    data.alpha.all.use <- na.omit(data.alpha.all[,c("PCoA1",permanova.var)])
    r1 <- cor(data.alpha.all.use[,"PCoA1"], as.numeric(data.alpha.all.use[,permanova.var]), method="pearson")
    data.alpha.all.use <- na.omit(data.alpha.all[,c("PCoA2",permanova.var)])
    r2 <- cor(data.alpha.all.use[,"PCoA2"], as.numeric(data.alpha.all.use[,permanova.var]), method="pearson")
    data.alpha.all.use <- na.omit(data.alpha.all[,c("PCoA3",permanova.var)])
    r3 <- cor(data.alpha.all.use[,"PCoA3"], as.numeric(data.alpha.all.use[,permanova.var]), method="pearson")
    data.alpha.all.use <- na.omit(data.alpha.all[,c("PCoA4",permanova.var)])
    r4 <- cor(data.alpha.all.use[,"PCoA4"], as.numeric(data.alpha.all.use[,permanova.var]), method="pearson")
    
    res <- data.frame(var=permanova.var, PCoA1=r1, PCoA2=r2, PCoA3=r3, PCoA4=r4)
    arrows <- rbind(arrows, res)
  }
  arrows <- merge(arrows, unique(data.map.use), by.x="var", by.y="Vars",all.x=T)
  
  data.alpha.all$SES.cat <- ifelse(data.alpha.all$cat_SES=="1.0-25%", "SES Q1",
                                   ifelse(data.alpha.all$cat_SES=="2.25-50%", "SES Q2",
                                          ifelse(data.alpha.all$cat_SES=="3.50-75%", "SES Q3","SES Q4")))
  

  save(data.alpha.all,arrows, file=paste(visit, "data.alpha.all.RData"))
  if(visit=="3 month"){
    pmain1 <- ggplot(data=subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(PCoA1, PCoA2))+
       geom_point(aes(col=SES.cat)) +
      stat_ellipse(aes(fill=SES.cat), alpha=1,type='t',size =1, geom="polygon") + ##changes shading on ellipses
      theme_bw() +
      theme(aspect.ratio = 1)+
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
      scale_color_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    pmain2 <- ggplot(data=subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(PCoA1, PCoA2))+
      # geom_point(aes(col=SES.cat)) +
      stat_ellipse(aes(fill=SES.cat), type='t',size =1, geom="polygon") + ##changes shading on ellipses
      theme_bw() +
      theme(aspect.ratio = 1)+
      geom_segment(data=arrows, aes(x=0, y=0, xend=PCoA1/0.02, yend=PCoA2/0.02), 
                   arrow=arrow(length=unit(.2, "cm")),color="gray", size=1) +
      geom_label_repel(data=arrows, aes(x=PCoA1/0.02, y=PCoA2/0.02, label=Label),
                       label.size = NA, 
                       fontface = 'bold', color = 'black',
                       max.overlaps = getOption("ggrepel.max.overlaps", default = 100),
                       box.padding = 0.80, point.padding = 0.5) +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
      scale_color_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    
    # Marginal densities along x axis
    my_comparisons <- list(c("SES Q1","SES Q2"),c("SES Q1","SES Q3"),c("SES Q1","SES Q4"))
    
    xdens <- axis_canvas(pmain1, axis = "x") +
      geom_boxplot(data = subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(x = PCoA1, fill = SES.cat),
                    size = 0.2)  +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    # Marginal densities along y axis
    # Need to set coord_flip = TRUE, if you plan to use coord_flip()
    ydens <- axis_canvas(pmain1, axis = "y", coord_flip = TRUE) +
      geom_boxplot(data = subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(x = PCoA2, fill = SES.cat),
                    size = 0.2)  +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
      coord_flip() 
    p1 <- insert_xaxis_grob(pmain2, xdens, grid::unit(.1, "null"), position = "top")
    p2 <- insert_yaxis_grob(p1, ydens, grid::unit(.1, "null"), position = "right")
    ggdraw(p2)
  }
  if(visit=="1 year"){
    pmain1 <- ggplot(data=subset(data.alpha.all,!is.na(MR1_latent.raw)), aes( PCoA1,PCoA3))+
      # geom_point(aes(col=SES.cat)) +
      stat_ellipse(aes(fill=SES.cat),type='t',size =1, geom="polygon") + ##changes shading on ellipses
      theme_bw() +
      theme(aspect.ratio = 1)+
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
      scale_color_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    pmain2 <- ggplot(data=subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(PCoA1, PCoA3))+
      # geom_point(aes(col=SES.cat)) +
      stat_ellipse(aes(fill=SES.cat),type='t',size =1, geom="polygon") + ##changes shading on ellipses
      theme_bw() +
      theme(aspect.ratio = 1)+
      geom_segment(data=arrows, aes(x=0, y=0, xend=PCoA1/0.02, yend=PCoA3/0.02), 
                   arrow=arrow(length=unit(.2, "cm")),color="gray", size=1) +
      geom_label_repel(data=arrows, aes(x=PCoA1/0.02, y=PCoA3/0.02, label=Label),
                       label.size = NA, 
                       fontface = 'bold', color = 'black',
                       max.overlaps = getOption("ggrepel.max.overlaps", default = 100),
                       box.padding = 0.80, point.padding = 0.5) +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
      scale_color_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    
    
    # Marginal densities along x axis
    my_comparisons <- list(c("SES Q1","SES Q2"),c("SES Q1","SES Q3"),c("SES Q1","SES Q4"))
    
    xdens <- axis_canvas(pmain1, axis = "x") +
      geom_boxplot(data = subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(x = PCoA1, fill = SES.cat),
                    size = 0.2) +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) 
    # Marginal densities along y axis
    # Need to set coord_flip = TRUE, if you plan to use coord_flip()
    ydens <- axis_canvas(pmain1, axis = "y", coord_flip = TRUE) +
      geom_boxplot(data = subset(data.alpha.all,!is.na(MR1_latent.raw)), aes(x = PCoA3, fill = SES.cat),
                   size = 0.2) +
      scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e"))  +
      coord_flip() 
    p1 <- insert_xaxis_grob(pmain2, xdens, grid::unit(.1, "null"), position = "top")
    p2 <- insert_yaxis_grob(p1, ydens, grid::unit(.1, "null"), position = "right")

  }
      
    pcoa.plot[[pco.i]] <-   p2 
    names(pcoa.plot)[pco.i] <- visit
    pco.i <- pco.i + 1
    
  data.alpha.all$Visit <- visit
  data.alpha.all.both <- rbind(data.alpha.all.both, data.alpha.all)
}


names(pcoa.plot)
## [1] "1 year"  "3 month"
pdf(paste("Figures/P3 Visit","PCOA Results.pdf"),height = 9, width=10)
plot( pcoa.plot[["3 month"]] )
plot( pcoa.plot[["1 year"]] )
dev.off()
## quartz_off_screen 
##                 2
plot( pcoa.plot[["3 month"]] )

plot( pcoa.plot[["1 year"]] )

lm.res <- data.frame(Visit=c(rep("3 month",3),rep("1 year",3)),
           variable=c(paste0("PCoA",1:3),paste0("PCoA",1:3)),
           pval=c(summary(lm(PCoA1 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="3 month")))$coef[2,4],
summary(lm(PCoA2 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="3 month")))$coef[2,4],
summary(lm(PCoA3 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="3 month")))$coef[2,4],
summary(lm(PCoA1 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="1 year")))$coef[2,4],
summary(lm(PCoA2 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="1 year")))$coef[2,4],
summary(lm(PCoA3 ~ MR1_latent.raw + exact_age + ProcessingPeriod, subset(data.alpha.all.both,Visit=="1 year")))$coef[2,4]))

lm.res$label.use <- paste0("Regression p-value=",signif(lm.res$pval,digits=2))
lm.res$Visit <- factor(lm.res$Visit, levels=c("3 month", "1 year"), ordered=T)
lm.res$pval <- signif(lm.res$pval, digits=2)

pdf("Figures/P3 PCoA ggplot.pdf", height=4, width=10)
library(reshape2)
data.pcoa <- melt(data.alpha.all.both[,c("subjectnumber","Visit","MR1_latent.raw","SES.cat","PCoA1","PCoA2","PCoA3","PCoA4")],
                  id.vars =c("subjectnumber","Visit","MR1_latent.raw","SES.cat") )
data.pcoa$Visit <- factor(data.pcoa$Visit, levels=c("3 month", "1 year"), ordered=T)
data.pcoa$Selected <- paste(data.pcoa$Visit,data.pcoa$variable,sep="_")
data.pcoa.select <- subset(data.pcoa, Selected %in%c("3 month_PCoA1", "3 month_PCoA2","1 year_PCoA3"))
data.pcoa.select$Selected <- factor(data.pcoa.select$Selected, levels=c("3 month_PCoA1", "3 month_PCoA2","1 year_PCoA3"), ordered = T)
lm.res$Selected <- paste(lm.res$Visit,lm.res$variable,sep="_")
lm.res.select <- subset(lm.res, Selected %in%c("3 month_PCoA1", "3 month_PCoA2","1 year_PCoA3"))
lm.res.select$Selected <- factor(lm.res.select$Selected, levels=c("3 month_PCoA1", "3 month_PCoA2","1 year_PCoA3"), ordered = T)

ggplot(data = subset(data.pcoa.select,!is.na(MR1_latent.raw)), aes(y = value, fill = SES.cat, x=SES.cat),
       alpha = 0.7, size = 0.2) +
  geom_boxplot() +
  scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  stat_compare_means(comparisons = my_comparisons, label="p.signif",
                     step.increase = 0.03, tip.length = 0.01) +
  facet_grid(~Selected, scale="free") +
  theme_bw() + xlab("SES quartiles") +
  geom_text(data=lm.res.select,
            aes(x = 4, y = -10,
                label=pval), parse = TRUE, inherit.aes=FALSE) 
dev.off()
## quartz_off_screen 
##                 2
pdf("Figures/P3 PCoA ggplot all.pdf", height=10, width=16)
ggplot(data = subset(data.pcoa,!is.na(MR1_latent.raw)), aes(y = value, fill = SES.cat, x=SES.cat),
       alpha = 0.7, size = 0.2) +
  geom_boxplot() +
  scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  stat_compare_means(comparisons = my_comparisons, label="p.signif",position = position_nudge(y = 2)) +
  facet_grid(Visit~variable, scale="free") +
  theme_bw() + xlab("SES quartiles") +
  geom_text(data=lm.res,
            aes(x = 4, y = -10,
                label=pval), parse = TRUE, inherit.aes=FALSE) 
dev.off()
## quartz_off_screen 
##                 2
ggplot(data = subset(data.pcoa,!is.na(MR1_latent.raw)), aes(y = value, fill = SES.cat, x=SES.cat),
       alpha = 0.7, size = 0.2) +
  geom_boxplot() +
  scale_fill_manual(values=c("#c3d7bd", "#a4c19a", "#5d836e", "#3f615e")) +
  stat_compare_means(comparisons = my_comparisons, label="p.signif",position = position_nudge(y = 2)) +
  facet_grid(variable~Visit, scale="free") +
  theme_bw() + xlab("SES quartiles") +
  geom_text(data=lm.res,
            aes(x = 4, y = -10,
                label=pval), parse = TRUE, inherit.aes=FALSE) 

pcoaVS.sp.3m <- ecodist::pco(varespec.bray.all$`3 month_Species`[[1]], negvals = "zero", dround = 0)
pcoaVS.sp.1y <- ecodist::pco(varespec.bray.all$`1 year_Species`[[1]], negvals = "zero", dround = 0)

pcoaVS.sp.3m$values[1]/sum(pcoaVS.sp.3m$values)
## [1] 0.08243889
pcoaVS.sp.3m$values[2]/sum(pcoaVS.sp.3m$values)
## [1] 0.07799098
pcoaVS.sp.1y$values[1]/sum(pcoaVS.sp.1y$values)
## [1] 0.1196784
pcoaVS.sp.1y$values[3]/sum(pcoaVS.sp.1y$values)
## [1] 0.04365229

Generate SEM model for SES affect PCOAs through early-life factors (Figure 2E)

# rm(list=ls())
# work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"
# setwd(work.dir)
# load("Results/P0 Clinical data with SES Index.RData")
# load("Results/P1 Processed Metagenomic data.RData")
# load("Results/P3 PCOA data.RData")
# load("Results/P2 Univariate Analysis of SES.Rdata")
# source("/Users/darlene.dai/Desktop/SES/Script/P4 SEM update model.R")
# ########################################################################################################
# ses.res <- subset(UVA.res.outcome, Adj.genetic==F & Variables=="MR1_latent.raw.interquartile" &
#                     !Variables%in%c("sitetoronto","sitevancouver","sitewinnipeg") &
#                     Cohort=="all")
# varespec.bray.use <- varespec.bray.all
# pcoaVS.sp.3m <- ecodist::pco(varespec.bray.use$`3 month_Species`[[1]], negvals = "zero", dround = 0) # if negvals = 0 sets all negative eigenvalues to zero; if = "rm" corrects for negative eigenvalues using method 1 of Legendre and Anderson 1999
# pcoaVS.sp.1y <- ecodist::pco(varespec.bray.use$`1 year_Species`[[1]], negvals = "zero", dround = 0) # if negvals = 0 sets all negative eigenvalues to zero; if = "rm" corrects for negative eigenvalues using method 1 of Legendre and Anderson 1999
# 
# data1 <- data.frame(subjectnumber=rownames(varespec.bray.all$`3 month_Species`[[2]]),
#                     sp.3m.PCoA1=scale(pcoaVS.sp.3m$vectors[,1]),
#                     sp.3m.PCoA2=scale(pcoaVS.sp.3m$vectors[,2]),
#                     sp.3m.PCoA3=scale(pcoaVS.sp.3m$vectors[,3]),
#                     sp.3m.PCoA4=scale(pcoaVS.sp.3m$vectors[,4]))
# data2 <- data.frame(subjectnumber=rownames(varespec.bray.all$`1 year_Species`[[2]]),
#                     sp.1y.PCoA1=scale(pcoaVS.sp.1y$vectors[,1]),
#                     sp.1y.PCoA2=scale(pcoaVS.sp.1y$vectors[,2]),
#                     sp.1y.PCoA3=scale(pcoaVS.sp.1y$vectors[,3]),
#                     sp.1y.PCoA4=scale(pcoaVS.sp.1y$vectors[,4]))
# data.pcoa <- merge(data1, data2,by="subjectnumber",all=T)
# data.pcoa <- merge(data.pcoa[,c("subjectnumber","sp.3m.PCoA1","sp.1y.PCoA1","sp.3m.PCoA2","sp.1y.PCoA2","sp.3m.PCoA3","sp.1y.PCoA3","sp.3m.PCoA4","sp.1y.PCoA4")],
#                    merge(subset(data.div, Visit=="3 month", select=c("SubjectNumber", "exact_age","ProcessingPeriod")),
#                          subset(data.div, Visit=="1 year", select=c("SubjectNumber", "exact_age","ProcessingPeriod")), suffixes = c(".3m",".1y"), by="SubjectNumber",all=T),
#                    by.x="subjectnumber", by.y ="SubjectNumber",all.x=T)
# outcome.vars <- c("asthma5y_ep","overweight","atopy5y", "Tscore_abnormal")
# data.sem <- merge(data.withmissing, data.pcoa, by="subjectnumber",all.x=T)
# data.sem$atbx.microbiome.new.1y <- as.numeric(as.character(data.sem$atbx.micro1y))
# data.sem$atbx.microbiome.new.3m <- as.numeric(as.character(data.sem$atbx.micro3m))
# data.sem$bf.3m <- ifelse(data.sem$exact_age.3m*12<data.sem$bf_duration_imp,1, 0)
# data.sem$bf.1y <- ifelse(data.sem$exact_age.1y*12<data.sem$bf_duration_imp,1, 0)
# 
# 
# cate.vars.all <- data.map$Vars[data.map$Type=="Categorical"]
# 
# 
# ###########################################################################
# 
# res.vars.list <- list(c("sp.3m.PCoA1"),c("sp.1y.PCoA3"))
# 
# cutoff.uses <- c(1.1)
# impute.uses <- c(T)
# SEM.RES.ALL <- vector("list")
# sem.i <- 1
# bf.vars.use <- c("bf")
# 
# for(bf.var.use in bf.vars.use){
#   for(cutoff.use in cutoff.uses){
#     for(resp.vars in res.vars.list){
# 
#       cov.use <- unique(c(ses.res$Response[ses.res$UVA_P<cutoff.use]))
# 
#       used.vars <- cov.use[!cov.use%in%c("EBF_6m", "bf_duration_imp")]
#       data.sem.use <-  data.sem[!is.na(data.sem$MR1_latent.raw),]
#       adj.main <- c("vancouver", "edmonton","toronto")
# 
#       m.main.all<- m.test.all <- cov.use.mediators.all <- adj.vars.all <- NULL
#       for(resp.var in resp.vars){
#         cov.use.mediators <- used.vars
#         if(resp.var%in%c("sp.3m.PCoA1","sp.3m.PCoA2","sp.3m.PCoA3","sp.3m.PCoA4")){
#           cov.use.mediators <- cov.use.mediators[!cov.use.mediators%in%c("maternaldistress_perceived_1y", "awayhome1h_1y")]
#           if("atbx.1y"%in%cov.use.mediators){
#             cov.use.mediators[cov.use.mediators=="atbx.1y"] <- "atbx.micro3m"
#           }
# 
#           if(bf.var.use=="bf"){
#             cov.use.mediators <- c( "bf.3m",cov.use.mediators)
#           }else{
#             cov.use.mediators <- c( "EBF_6m",cov.use.mediators)
#           }
#           adj.vars <- c(adj.main, "ProcessingPeriod.3m","exact_age.3m")
#           m.main <- paste(resp.var, " ~ dir1*MR1_latent.raw +", paste(paste0("mm",resp.var,cov.use.mediators,"*",cov.use.mediators),collapse=" + "), " + ",paste(adj.vars, collapse = " + "))
#           m.test <- paste0("ind_",resp.var,"_",cov.use.mediators, " := ", paste0("mr",cov.use.mediators), "*", paste0("mm",resp.var,cov.use.mediators))
#         }
# 
#         if(resp.var%in%c("sp.1y.PCoA1","sp.1y.PCoA2","sp.1y.PCoA3","sp.1y.PCoA4")){
#           if("atbx.1y"%in%cov.use.mediators){
#             cov.use.mediators[cov.use.mediators=="atbx.1y"] <- "atbx.micro1y"
#           }
#           if(bf.var.use=="bf"){
#             cov.use.mediators <- c( "bf.1y",cov.use.mediators)
#           }else{
#             cov.use.mediators <- c( "EBF_6m",cov.use.mediators)
#           }
#           adj.vars <- c(adj.main, "ProcessingPeriod.1y","exact_age.1y")
#           m.main <- paste(resp.var, " ~ dir1*MR1_latent.raw +", paste(paste0("mm",resp.var,cov.use.mediators,"*",cov.use.mediators),collapse=" + "), " + ",paste(adj.vars, collapse = " + "))
#           m.test <- paste0("ind_",resp.var,"_",cov.use.mediators, " := ", paste0("mr",cov.use.mediators), "*", paste0("mm",resp.var,cov.use.mediators))
#         }
#         add.m <- NULL
#         if("bf.3m"%in%cov.use.mediators.all & "bf.1y"%in%cov.use.mediators.all){
#           add.m <- c(add.m, "bf.3m ~~ bf.1y")
#         }
#         m.main.all <- c(m.main.all, m.main)
#         m.test.all <- c(m.test.all, m.test)
#         cov.use.mediators.all <- unique(c(cov.use.mediators.all, cov.use.mediators))
#         adj.vars.all <- unique(c(adj.vars.all, adj.vars))
#       }
#       m.each <- c(paste(cov.use.mediators.all,"~ ", paste0("mr",cov.use.mediators.all), "*MR1_latent.raw"," + ",paste(adj.main, collapse = " + ") ))
#       used.all.vars <- c(resp.vars, cov.use.mediators.all)
#       for(j in 1:length(used.all.vars)){
#         data.sem.use[,used.all.vars[j]] <- as.numeric(as.character(data.sem.use[,used.all.vars[j]] ))
#       }
# 
#       if("sp.3m.PCoA1"%in%resp.vars | "sp.1y.PCoA3"%in%resp.vars){
#         change.bf.id <- which(gsub("bf.3m ~ ","",m.each)!=m.each | gsub("bf_duration.3m ~ ","",m.each)!=m.each |
#                                 gsub("atbx.micro3m ~ ","",m.each)!=m.each)
#         if(length(change.bf.id)>0){
#           m.each[change.bf.id] <- paste(m.each[change.bf.id], "+ exact_age.3m")
#         }
#         change.bf.id <- which(gsub("bf.1y ~ ","",m.each)!=m.each |
#                                 gsub("bf_duration.1y ~ ","",m.each)!=m.each |
#                                 gsub("atbx.micro1y ~ ","",m.each)!=m.each)
#         if(length(change.bf.id)>0){
#           m.each[change.bf.id] <- paste(m.each[change.bf.id], "+ exact_age.1y")
#         }
#       }
# 
#       model.use <- c(m.main.all, m.each, add.m, m.test.all)
#       model.all <- sem(paste(model.use,sep="\n"),
#                        data=data.sem.use,
#                        ordered=used.all.vars[used.all.vars%in%cate.vars.all],
#                        missing="pairwise")
#       summary(model.all)
#       kk <- parameterEstimates(model.all,standardized = T)
#       kk.use <- kk[gsub("ind_","",kk$lhs)!=kk$lhs,]
#       mod_indices <- modindices(model.all, sort = TRUE, alpha=0.05)
#       adj.M <- updatemodel(mod_indices,
#                            var.add.covs=list(c(cov.use.mediators.all)),
#                            model.use,
#                            data.sem.use,
#                            ordered.vars=used.all.vars[used.all.vars%in%cate.vars.all],
#                            missing.use="pairwise")
#       adj.M.use <- adj.M
#       model.use.final <- c(model.use, adj.M.use)
#       model.all.final <- sem(paste(model.use.final,collapse = "\n"),
#                              data=data.sem.use,
#                              ordered=used.all.vars[used.all.vars%in%cate.vars.all],
#                              missing="pairwise")
# 
# 
#       SEM.RES.ALL[[sem.i]] <- list(model.use.final, model.all.final)
#       names(SEM.RES.ALL)[sem.i] <- paste(resp.vars,cutoff.use,bf.var.use,collapse = "_")
#       sem.i <- sem.i + 1
#       save(SEM.RES.ALL, file="Results/P2 SEM of SES on PCOAs through factors.RData")
#     }
#   }
# }


load("Results/P2 SEM of SES on PCOAs through factors.RData")
# used.test <- "sp.3m.PCoA1 0.05 bf_sp.3m.PCoA2 0.05 bf_sp.3m.PCoA3 0.05 bf" 
# used.test <-  "sp.1y.PCoA1 0.05 bf_sp.1y.PCoA2 0.05 bf_sp.1y.PCoA3 0.05 bf"
names(SEM.RES.ALL)
## [1] "sp.3m.PCoA1 0.05 bf" "sp.1y.PCoA3 0.05 bf" "sp.3m.PCoA1 1.1 bf" 
## [4] "sp.1y.PCoA3 1.1 bf"
used.test <-  "sp.3m.PCoA1 1.1 bf"  
model.all.final <- SEM.RES.ALL[[used.test]][[2]]
kk <- parameterEstimates(model.all.final,standardized = T)
kk.use <- kk[gsub("ind_","",kk$lhs)!=kk$lhs,]
dd <- subset(kk.use, pvalue<0.05)
FIT <- as.data.frame(t(summary(model.all.final, fit.measures=TRUE)$fit[c("cfi","tli","srmr","rmsea")]))
FIT
##         cfi       tli      srmr       rmsea
## 1 0.9937728 0.9927751 0.0797722 0.006898163
dd
##                       lhs op                        rhs                 label
## 449 ind_sp.3m.PCoA1_bf.3m := mrbf.3m*mmsp.3m.PCoA1bf.3m ind_sp.3m.PCoA1_bf.3m
##      est    se     z pvalue ci.lower ci.upper std.lv std.all std.nox
## 449 0.08 0.019 4.146      0    0.042    0.118   0.08   0.048    0.08
unique(c(subset(kk,lhs=="sp.3m.PCoA1")$rhs))
##  [1] "MR1_latent.raw"                                
##  [2] "bf.3m"                                         
##  [3] "atbx.micro3m"                                  
##  [4] "atbx.m.birth"                                  
##  [5] "atbx.m.preg"                                   
##  [6] "awayhome1h_3m"                                 
##  [7] "bw_sd"                                         
##  [8] "canue_Zdweldensity_pre18w"                     
##  [9] "cat_1y"                                        
## [10] "condition_GestationalDiabetes_mother_prelabour"
## [11] "dog_1y"                                        
## [12] "fasthma"                                       
## [13] "father_atopy_1y"                               
## [14] "freq_score_basic"                              
## [15] "gest_days"                                     
## [16] "hometype_3m"                                   
## [17] "masthma"                                       
## [18] "maternaldistress_perceived_pre18w"             
## [19] "mom_bmi_best"                                  
## [20] "mom_UPFContr"                                  
## [21] "mother_atopy_1y"                               
## [22] "no2.preg"                                      
## [23] "no2.y1"                                        
## [24] "num_siblings"                                  
## [25] "postnatal_smoke"                               
## [26] "Pregnancy.Tdens250"                            
## [27] "prenatal_smoke"                                
## [28] "rural"                                         
## [29] "furniture_densityclutter_3m"                   
## [30] "home_plant_3m"                                 
## [31] "floor_carpet_3m"                               
## [32] "mould_3m_mh"                                   
## [33] "vaginal"                                       
## [34] "fall"                                          
## [35] "summer"                                        
## [36] "winter"                                        
## [37] "vancouver"                                     
## [38] "edmonton"                                      
## [39] "toronto"                                       
## [40] "ProcessingPeriod.3m"                           
## [41] "exact_age.3m"                                  
## [42] "sp.3m.PCoA1"                                   
## [43] ""
kk.use[,c("label","est","pvalue","std.all")]
##                                                              label    est
## 449                                          ind_sp.3m.PCoA1_bf.3m  0.080
## 450                                   ind_sp.3m.PCoA1_atbx.micro3m -0.005
## 451                                   ind_sp.3m.PCoA1_atbx.m.birth  0.000
## 452                                    ind_sp.3m.PCoA1_atbx.m.preg  0.007
## 453                                  ind_sp.3m.PCoA1_awayhome1h_3m  0.015
## 454                                          ind_sp.3m.PCoA1_bw_sd  0.001
## 455                      ind_sp.3m.PCoA1_canue_Zdweldensity_pre18w -0.001
## 456                                         ind_sp.3m.PCoA1_cat_1y  0.003
## 457 ind_sp.3m.PCoA1_condition_GestationalDiabetes_mother_prelabour  0.084
## 458                                         ind_sp.3m.PCoA1_dog_1y  0.000
## 459                                        ind_sp.3m.PCoA1_fasthma  0.000
## 460                                ind_sp.3m.PCoA1_father_atopy_1y -0.002
## 461                               ind_sp.3m.PCoA1_freq_score_basic -0.001
## 462                                      ind_sp.3m.PCoA1_gest_days -0.013
## 463                                    ind_sp.3m.PCoA1_hometype_3m -0.005
## 464                                        ind_sp.3m.PCoA1_masthma  0.001
## 465              ind_sp.3m.PCoA1_maternaldistress_perceived_pre18w -0.009
## 466                                   ind_sp.3m.PCoA1_mom_bmi_best -0.031
## 467                                   ind_sp.3m.PCoA1_mom_UPFContr  0.000
## 468                                ind_sp.3m.PCoA1_mother_atopy_1y  0.004
## 469                                       ind_sp.3m.PCoA1_no2.preg -0.004
## 470                                         ind_sp.3m.PCoA1_no2.y1  0.006
## 471                                   ind_sp.3m.PCoA1_num_siblings  0.000
## 472                                ind_sp.3m.PCoA1_postnatal_smoke  0.024
## 473                             ind_sp.3m.PCoA1_Pregnancy.Tdens250 -0.003
## 474                                 ind_sp.3m.PCoA1_prenatal_smoke -0.010
## 475                                          ind_sp.3m.PCoA1_rural  0.001
## 476                    ind_sp.3m.PCoA1_furniture_densityclutter_3m  0.022
## 477                                  ind_sp.3m.PCoA1_home_plant_3m  0.001
## 478                                ind_sp.3m.PCoA1_floor_carpet_3m  0.008
## 479                                    ind_sp.3m.PCoA1_mould_3m_mh -0.004
## 480                                        ind_sp.3m.PCoA1_vaginal  0.000
## 481                                           ind_sp.3m.PCoA1_fall -0.001
## 482                                         ind_sp.3m.PCoA1_summer -0.003
## 483                                         ind_sp.3m.PCoA1_winter  0.002
##     pvalue std.all
## 449  0.000   0.048
## 450  0.666  -0.003
## 451  0.922   0.000
## 452  0.486   0.004
## 453  0.196   0.009
## 454  0.690   0.000
## 455  0.779  -0.001
## 456  0.743   0.002
## 457  0.073   0.050
## 458  0.973   0.000
## 459  0.832   0.000
## 460  0.811  -0.001
## 461  0.817  -0.001
## 462  0.117  -0.008
## 463  0.888  -0.003
## 464  0.769   0.000
## 465  0.726  -0.005
## 466  0.139  -0.018
## 467  0.981   0.000
## 468  0.393   0.002
## 469  0.585  -0.002
## 470  0.490   0.004
## 471  0.791   0.000
## 472  0.865   0.014
## 473  0.744  -0.002
## 474  0.927  -0.006
## 475  0.957   0.000
## 476  0.391   0.013
## 477  0.938   0.000
## 478  0.246   0.005
## 479  0.738  -0.002
## 480  0.910   0.000
## 481  0.706  -0.001
## 482  0.521  -0.002
## 483  0.636   0.001
kk[kk$lhs=="sp.3m.PCoA1" & kk$pvalue<0.05,c("rhs","std.all","pvalue")]
##                                                rhs std.all pvalue
## 2                                            bf.3m   0.270  0.000
## 5                                      atbx.m.preg  -0.099  0.042
## 6                                    awayhome1h_3m  -0.101  0.038
## 10  condition_GestationalDiabetes_mother_prelabour  -0.260  0.026
## 14                                freq_score_basic  -0.079  0.038
## 31                                 floor_carpet_3m  -0.092  0.046
## 41                                    exact_age.3m  -0.107  0.000
## 327                                    sp.3m.PCoA1   0.771  0.000
kk[kk$rhs=="MR1_latent.raw" & kk$pvalue<0.05,c("lhs","std.all","pvalue")]
##                                                lhs std.all pvalue
## 42                                           bf.3m   0.177  0.000
## 76  condition_GestationalDiabetes_mother_prelabour  -0.193  0.004
## 96                                       gest_days   0.101  0.001
## 100                                    hometype_3m  -0.240  0.000
## 108              maternaldistress_perceived_pre18w  -0.283  0.000
## 112                                   mom_bmi_best  -0.233  0.000
## 116                                   mom_UPFContr  -0.151  0.000
## 136                                postnatal_smoke  -0.387  0.000
## 140                             Pregnancy.Tdens250   0.112  0.000
## 144                                 prenatal_smoke  -0.322  0.000
## 152                    furniture_densityclutter_3m  -0.205  0.000
## 156                                  home_plant_3m   0.106  0.008
## 164                                    mould_3m_mh  -0.115  0.021
## NA                                            <NA>      NA     NA
summary(model.all.final, fit=T)
## lavaan 0.6-19 ended normally after 738 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       352
## 
##                                                   Used       Total
##   Number of observations                          1221        2752
##   Number of missing patterns                       182            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               574.523     565.899
##   Degrees of freedom                               543         543
##   P-value (Chi-square)                           0.169       0.240
##   Scaling correction factor                                  1.377
##   Shift parameter                                          148.551
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                              5692.122    4112.900
##   Degrees of freedom                               630         630
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.453
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.994       0.993
##   Tucker-Lewis Index (TLI)                       0.993       0.992
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.007       0.006
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.012       0.011
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.080       0.080
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                                                    Estimate  Std.Err  z-value
##   sp.3m.PCoA1 ~                                                              
##                             (dir1)                    0.048    0.090    0.535
##                  (mmsp.3m.PCA1b.3)                    0.705    0.083    8.500
##                  (mmsp.3m.PCA1t.3)                    0.056    0.110    0.510
##              (mmsp.3m.PCA1tbx.m.b)                   -0.010    0.059   -0.179
##              (mmsp.3m.PCA1tbx.m.p)                   -0.099    0.049   -2.031
##                        (m.3.PCA11)                   -0.100    0.048   -2.074
##                   (mmsp.3m.PCA1b_)                   -0.018    0.034   -0.530
##                       (m.3.PCA1_Z)                   -0.010    0.033   -0.290
##                  (mmsp.3m.PCA1c_1)                   -0.108    0.063   -1.709
##                       (m.3.PCA1_G)                   -0.254    0.114   -2.221
##                  (mmsp.3m.PCA1d_1)                   -0.014    0.062   -0.232
##                   (mmsp.3m.PCA1fs)                   -0.014    0.056   -0.256
##                 (mmsp.3m.PCA1f__1)                   -0.014    0.057   -0.241
##                  (mmsp.3m.PCA1f__)                   -0.008    0.004   -2.078
##                   (mmsp.3m.PCA1g_)                   -0.008    0.005   -1.836
##                      (mm.3.PCA1_3)                    0.011    0.079    0.141
##                    (mmsp.3m.PCA1m)                    0.014    0.045    0.316
##                     (m.3.PCA1__18)                    0.003    0.008    0.351
##                  (mmsp.3m.PCA1m__)                    0.015    0.010    1.503
##                       (m.3.PCA1_U)                    0.000    0.005    0.024
##                 (mmsp.3m.PCA1m__1)                    0.055    0.042    1.314
##                      (mm.3.PCA12.)                   -0.019    0.030   -0.635
##                      (m.3.PCA12.1)                    0.035    0.040    0.866
##                   (mmsp.3m.PCA1n_)                    0.025    0.072    0.347
##                  (mmsp.3m.PCA1ps_)                   -0.034    0.200   -0.171
##                        (m.3.PCA1P)                   -0.001    0.002   -0.328
##                  (mmsp.3m.PCA1pr_)                    0.017    0.190    0.092
##                    (mmsp.3m.PCA1r)                   -0.008    0.148   -0.054
##                (mmsp.3m.PCA1fr__3)                   -0.063    0.072   -0.872
##                 (mmsp.3m.PCA1h__3)                    0.003    0.037    0.078
##                (mmsp.3m.PCA1fl__3)                   -0.085    0.043   -1.996
##                      (m.3.PCA1_3_)                    0.019    0.054    0.340
##                    (mmsp.3m.PCA1v)                   -0.006    0.051   -0.116
##                   (mmsp.3m.PCA1fl)                    0.041    0.039    1.049
##                    (mmsp.3m.PCA1s)                    0.026    0.038    0.688
##                    (mmsp.3m.PCA1w)                   -0.025    0.046   -0.536
##                                                       0.172    0.201    0.857
##                                                      -0.008    0.172   -0.047
##                                                      -0.054    0.229   -0.234
##                                                       0.002    0.002    0.952
##                                                      -1.129    0.300   -3.762
##   bf.3m ~                                                                    
##                            (mrb.3)                    0.114    0.024    4.762
##                                                       0.107    0.039    2.742
##                                                       0.012    0.031    0.391
##                                                       0.003    0.033    0.087
##                                                      -0.686    0.129   -5.309
##   atbx.micro3m ~                                                             
##                            (mrt.3)                   -0.085    0.105   -0.811
##                                                       0.047    0.168    0.282
##                                                       0.205    0.173    1.184
##                                                      -0.057    0.193   -0.295
##                                                       0.885    0.644    1.375
##   atbx.m.birth ~                                                             
##                        (mrtbx.m.b)                   -0.010    0.084   -0.116
##                                                       0.353    0.125    2.816
##                                                       0.057    0.147    0.390
##                                                       0.129    0.145    0.893
##   atbx.m.preg ~                                                              
##                        (mrtbx.m.p)                   -0.070    0.095   -0.740
##                                                      -0.161    0.139   -1.162
##                                                      -0.154    0.154   -1.006
##                                                      -0.121    0.151   -0.800
##   awayhome1h_3m ~                                                            
##                             (m1_3)                   -0.151    0.090   -1.667
##                                                      -0.015    0.145   -0.106
##                                                      -0.056    0.163   -0.343
##                                                       0.134    0.156    0.856
##   bw_sd ~                                                                    
##                             (mrb_)                   -0.031    0.052   -0.605
##                                                      -0.012    0.078   -0.150
##                                                      -0.090    0.084   -1.078
##                                                      -0.165    0.088   -1.888
##   canue_Zdweldensity_pre18w ~                                                
##                             (m_Z_)                    0.106    0.097    1.093
##                                                       1.854    0.250    7.419
##                                                      -0.034    0.501   -0.069
##                                                       2.094    0.257    8.160
##   cat_1y ~                                                                   
##                            (mrc_1)                   -0.026    0.078   -0.333
##                                                      -0.019    0.120   -0.160
##                                                       0.081    0.138    0.592
##                                                      -0.081    0.139   -0.582
##   condition_GestationalDiabetes_mother_prelabour ~                           
##                             (m_GD)                   -0.331    0.116   -2.860
##                                                       0.446    0.204    2.187
##                                                       0.374    0.229    1.630
##                                                       0.369    0.237    1.555
##   dog_1y ~                                                                   
##                            (mrd_1)                    0.003    0.082    0.034
##                                                      -0.541    0.122   -4.426
##                                                      -0.004    0.128   -0.034
##                                                      -0.337    0.133   -2.533
##   fasthma ~                                                                  
##                             (mrfs)                   -0.032    0.084   -0.378
##                                                       0.120    0.122    0.983
##                                                       0.154    0.149    1.032
##                                                      -0.160    0.137   -1.168
##   father_atopy_1y ~                                                          
##                           (mrf__1)                    0.148    0.080    1.859
##                                                       0.270    0.115    2.359
##                                                       0.206    0.143    1.439
##                                                       0.385    0.126    3.066
##   freq_score_basic ~                                                         
##                            (mrf__)                    0.124    0.536    0.232
##                                                      -3.019    0.817   -3.696
##                                                       0.615    0.936    0.657
##                                                       1.722    0.842    2.044
##   gest_days ~                                                                
##                             (mrg_)                    1.571    0.494    3.180
##                                                      -2.301    0.726   -3.170
##                                                      -1.565    0.810   -1.931
##                                                      -1.573    0.861   -1.827
##   hometype_3m ~                                                              
##                             (mr_3)                   -0.476    0.075   -6.314
##                                                       1.560    0.122   12.827
##                                                       0.036    0.152    0.238
##                                                       1.052    0.134    7.839
##   masthma ~                                                                  
##                             (mrms)                    0.055    0.075    0.734
##                                                      -0.166    0.116   -1.424
##                                                       0.078    0.126    0.618
##                                                       0.132    0.123    1.072
##   maternaldistress_perceived_pre18w ~                                        
##                            (m__18)                   -2.957    0.320   -9.230
##                                                       0.521    0.502    1.039
##                                                       0.721    0.595    1.212
##                                                       1.169    0.534    2.188
##   mom_bmi_best ~                                                             
##                            (mrm__)                   -1.977    0.257   -7.690
##                                                      -1.008    0.440   -2.291
##                                                       0.385    0.437    0.881
##                                                      -0.204    0.460   -0.443
##   mom_UPFContr ~                                                             
##                             (m_UP)                   -2.644    0.516   -5.125
##                                                      -2.742    0.851   -3.221
##                                                      -1.780    0.915   -1.945
##                                                      -0.295    0.923   -0.320
##   mother_atopy_1y ~                                                          
##                           (mrm__1)                    0.076    0.067    1.122
##                                                       0.434    0.104    4.168
##                                                       0.437    0.117    3.732
##                                                       0.488    0.113    4.326
##   no2.preg ~                                                                 
##                             (mr2.)                    0.212    0.194    1.096
##                                                       7.414    0.382   19.411
##                                                       7.496    0.397   18.897
##                                                      12.600    0.377   33.407
##   no2.y1 ~                                                                   
##                             (m2.1)                    0.183    0.162    1.126
##                                                       5.705    0.320   17.853
##                                                       6.714    0.333   20.170
##                                                      11.151    0.310   35.951
##   num_siblings ~                                                             
##                             (mrn_)                   -0.016    0.039   -0.416
##                                                      -0.209    0.066   -3.158
##                                                      -0.120    0.070   -1.715
##                                                      -0.359    0.067   -5.326
##   postnatal_smoke ~                                                          
##                            (mrps_)                   -0.711    0.085   -8.374
##                                                      -0.191    0.127   -1.505
##                                                       0.036    0.134    0.265
##                                                       0.002    0.142    0.011
##   Pregnancy.Tdens250 ~                                                       
##                             (mP.T)                    4.034    0.991    4.069
##                                                       1.689    2.535    0.666
##                                                      -7.050    2.966   -2.377
##                                                      30.082    2.104   14.300
##   prenatal_smoke ~                                                           
##                            (mrpr_)                   -0.587    0.078   -7.487
##                                                      -0.400    0.128   -3.113
##                                                      -0.078    0.133   -0.585
##                                                      -0.154    0.133   -1.159
##   rural ~                                                                    
##                             (mrrr)                   -0.077    0.138   -0.560
##                                                      -1.601    0.355   -4.507
##                                                      -0.879    0.210   -4.192
##                                                      -1.113    0.200   -5.560
##   furniture_densityclutter_3m ~                                              
##                          (mrfr__3)                   -0.357    0.077   -4.619
##                                                      -0.287    0.123   -2.326
##                                                      -0.241    0.136   -1.766
##                                                      -0.216    0.139   -1.561
##   home_plant_3m ~                                                            
##                           (mrh__3)                    0.184    0.069    2.661
##                                                       0.531    0.107    4.952
##                                                       0.206    0.117    1.764
##                                                       0.088    0.113    0.776
##   floor_carpet_3m ~                                                          
##                          (mrfl__3)                   -0.099    0.069   -1.433
##                                                      -0.004    0.104   -0.040
##                                                       0.462    0.125    3.708
##                                                      -0.669    0.115   -5.802
##   mould_3m_mh ~                                                              
##                             (m_3_)                   -0.201    0.087   -2.307
##                                                       0.273    0.133    2.060
##                                                      -0.381    0.194   -1.961
##                                                       0.504    0.147    3.440
##   vaginal ~                                                                  
##                             (mrvg)                   -0.035    0.074   -0.477
##                                                      -0.140    0.113   -1.235
##                                                      -0.051    0.127   -0.400
##                                                      -0.290    0.121   -2.401
##   fall ~                                                                     
##                             (mrfl)                   -0.031    0.076   -0.404
##                                                       0.150    0.112    1.340
##                                                      -0.004    0.128   -0.034
##                                                      -0.205    0.128   -1.603
##   summer ~                                                                   
##                             (mrsm)                   -0.125    0.070   -1.770
##                                                       0.245    0.109    2.251
##                                                      -0.026    0.133   -0.198
##                                                      -0.140    0.118   -1.185
##   winter ~                                                                   
##                             (mrwn)                   -0.078    0.074   -1.058
##                                                      -0.040    0.118   -0.335
##                                                       0.189    0.127    1.481
##                                                       0.308    0.124    2.493
##   P(>|z|)
##          
##     0.593
##     0.000
##     0.610
##     0.858
##     0.042
##     0.038
##     0.596
##     0.772
##     0.087
##     0.026
##     0.817
##     0.798
##     0.809
##     0.038
##     0.066
##     0.888
##     0.752
##     0.726
##     0.133
##     0.981
##     0.189
##     0.526
##     0.387
##     0.728
##     0.865
##     0.743
##     0.927
##     0.957
##     0.383
##     0.938
##     0.046
##     0.734
##     0.908
##     0.294
##     0.491
##     0.592
##     0.392
##     0.962
##     0.815
##     0.341
##     0.000
##          
##     0.000
##     0.006
##     0.695
##     0.931
##     0.000
##          
##     0.417
##     0.778
##     0.236
##     0.768
##     0.169
##          
##     0.908
##     0.005
##     0.696
##     0.372
##          
##     0.459
##     0.245
##     0.315
##     0.424
##          
##     0.095
##     0.916
##     0.732
##     0.392
##          
##     0.545
##     0.881
##     0.281
##     0.059
##          
##     0.275
##     0.000
##     0.945
##     0.000
##          
##     0.739
##     0.873
##     0.554
##     0.561
##          
##     0.004
##     0.029
##     0.103
##     0.120
##          
##     0.973
##     0.000
##     0.973
##     0.011
##          
##     0.705
##     0.325
##     0.302
##     0.243
##          
##     0.063
##     0.018
##     0.150
##     0.002
##          
##     0.817
##     0.000
##     0.511
##     0.041
##          
##     0.001
##     0.002
##     0.053
##     0.068
##          
##     0.000
##     0.000
##     0.812
##     0.000
##          
##     0.463
##     0.155
##     0.537
##     0.284
##          
##     0.000
##     0.299
##     0.225
##     0.029
##          
##     0.000
##     0.022
##     0.378
##     0.658
##          
##     0.000
##     0.001
##     0.052
##     0.749
##          
##     0.262
##     0.000
##     0.000
##     0.000
##          
##     0.273
##     0.000
##     0.000
##     0.000
##          
##     0.260
##     0.000
##     0.000
##     0.000
##          
##     0.677
##     0.002
##     0.086
##     0.000
##          
##     0.000
##     0.132
##     0.791
##     0.991
##          
##     0.000
##     0.505
##     0.017
##     0.000
##          
##     0.000
##     0.002
##     0.559
##     0.246
##          
##     0.575
##     0.000
##     0.000
##     0.000
##          
##     0.000
##     0.020
##     0.077
##     0.118
##          
##     0.008
##     0.000
##     0.078
##     0.438
##          
##     0.152
##     0.968
##     0.000
##     0.000
##          
##     0.021
##     0.039
##     0.050
##     0.001
##          
##     0.633
##     0.217
##     0.689
##     0.016
##          
##     0.686
##     0.180
##     0.973
##     0.109
##          
##     0.077
##     0.024
##     0.843
##     0.236
##          
##     0.290
##     0.738
##     0.138
##     0.013
## 
## Covariances:
##                                                     Estimate  Std.Err  z-value
##  .no2.preg ~~                                                                 
##    .no2.y1                                             6.841    0.194   35.259
##  .canue_Zdweldensity_pre18w ~~                                                
##    .no2.preg                                           2.810    0.096   29.121
##  .postnatal_smoke ~~                                                          
##    .prenatal_smoke                                     0.807    0.029   28.169
##  .canue_Zdweldensity_pre18w ~~                                                
##    .no2.y1                                             1.725    0.077   22.286
##    .hometype_3m                                        0.602    0.039   15.440
##  .hometype_3m ~~                                                              
##    .no2.preg                                           1.157    0.113   10.197
##  .no2.y1 ~~                                                                   
##    .rural                                             -1.174    0.137   -8.559
##  .hometype_3m ~~                                                              
##    .no2.y1                                             0.770    0.095    8.132
##  .fasthma ~~                                                                  
##    .father_atpy_1y                                     0.414    0.058    7.159
##  .hometype_3m ~~                                                              
##    .num_siblings                                      -0.205    0.030   -6.927
##  .masthma ~~                                                                  
##    .mother_atpy_1y                                     0.308    0.047    6.579
##  .bw_sd ~~                                                                    
##    .mom_bmi_best                                       0.802    0.126    6.372
##  .no2.preg ~~                                                                 
##    .rural                                             -1.240    0.213   -5.830
##  .bf.3m ~~                                                                    
##    .mom_bmi_best                                      -0.261    0.051   -5.097
##  .dog_1y ~~                                                                   
##    .freq_score_bsc                                     2.091    0.415    5.036
##  .furniture_densityclutter_3m ~~                                              
##    .mould_3m_mh                                        0.308    0.061    5.032
##  .bw_sd ~~                                                                    
##    .num_siblings                                       0.101    0.020    4.985
##  .bf.3m ~~                                                                    
##    .freq_score_bsc                                    -0.570    0.117   -4.870
##  .canue_Zdweldensity_pre18w ~~                                                
##    .num_siblings                                      -0.185    0.040   -4.673
##  .no2.preg ~~                                                                 
##    .winter                                            -0.585    0.125   -4.667
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .gest_days                                         -2.172    0.475   -4.574
##    .mom_bmi_best                                       1.191    0.266    4.483
##  .dog_1y ~~                                                                   
##    .hometype_3m                                       -0.262    0.059   -4.447
##  .no2.y1 ~~                                                                   
##    .floor_carpt_3m                                    -0.427    0.101   -4.246
##  .hometype_3m ~~                                                              
##    .frntr_dnstyc_3                                     0.237    0.057    4.164
##  .num_siblings ~~                                                             
##    .prenatal_smoke                                    -0.114    0.027   -4.151
##  .atbx.micro3m ~~                                                             
##    .gest_days                                         -1.559    0.380   -4.101
##  .canue_Zdweldensity_pre18w ~~                                                
##    .rural                                             -0.490    0.120   -4.080
##  .bf.3m ~~                                                                    
##    .prenatal_smoke                                    -0.064    0.016   -4.072
##  .maternaldistress_perceived_pre18w ~~                                        
##    .prenatal_smoke                                     1.006    0.254    3.961
##  .cat_1y ~~                                                                   
##    .frntr_dnstyc_3                                     0.234    0.059    3.932
##  .no2.y1 ~~                                                                   
##    .Prgnncy.Tdn250                                     2.995    0.771    3.887
##  .freq_score_basic ~~                                                         
##    .mom_bmi_best                                       5.200    1.381    3.765
##  .gest_days ~~                                                                
##    .num_siblings                                      -0.765    0.204   -3.753
##  .freq_score_basic ~~                                                         
##    .mom_UPFContr                                      10.338    2.772    3.730
##  .no2.preg ~~                                                                 
##    .num_siblings                                      -0.304    0.082   -3.691
##  .freq_score_basic ~~                                                         
##    .no2.y1                                            -2.525    0.687   -3.674
##  .mom_bmi_best ~~                                                             
##    .mom_UPFContr                                       5.161    1.408    3.665
##  .mom_UPFContr ~~                                                             
##    .postnatal_smok                                     1.684    0.461    3.651
##  .no2.y1 ~~                                                                   
##    .frntr_dnstyc_3                                     0.441    0.121    3.649
##  .masthma ~~                                                                  
##    .mom_bmi_best                                       0.655    0.182    3.601
##  .num_siblings ~~                                                             
##    .postnatal_smok                                    -0.105    0.029   -3.599
##  .no2.preg ~~                                                                 
##    .frntr_dnstyc_3                                     0.484    0.135    3.578
##  .mom_bmi_best ~~                                                             
##    .vaginal                                           -0.641    0.180   -3.560
##  .dog_1y ~~                                                                   
##    .num_siblings                                      -0.106    0.031   -3.411
##  .cat_1y ~~                                                                   
##    .postnatal_smok                                     0.210    0.062    3.368
##  .fasthma ~~                                                                  
##    .mom_bmi_best                                       0.679    0.202    3.359
##  .freq_score_basic ~~                                                         
##    .prenatal_smoke                                     1.325    0.395    3.358
##  .no2.preg ~~                                                                 
##    .floor_carpt_3m                                    -0.369    0.113   -3.270
##  .gest_days ~~                                                                
##    .vaginal                                            1.093    0.346    3.158
##  .num_siblings ~~                                                             
##    .vaginal                                            0.093    0.030    3.129
##  .cat_1y ~~                                                                   
##    .Prgnncy.Tdn250                                     2.697    0.865    3.119
##  .mom_bmi_best ~~                                                             
##    .home_plant_3m                                     -0.564    0.181   -3.119
##  .hometype_3m ~~                                                              
##    .winter                                             0.167    0.053    3.116
##  .maternaldistress_perceived_pre18w ~~                                        
##    .mom_bmi_best                                       2.659    0.855    3.111
##  .freq_score_basic ~~                                                         
##    .frntr_dnstyc_3                                    -1.203    0.393   -3.059
##    .mtrnldstrs__18                                     4.992    1.640    3.044
##  .hometype_3m ~~                                                              
##    .Prgnncy.Tdn250                                    -1.808    0.598   -3.025
##  .masthma ~~                                                                  
##    .mtrnldstrs__18                                     0.730    0.242    3.021
##  .mom_bmi_best ~~                                                             
##    .frntr_dnstyc_3                                     0.577    0.191    3.019
##  .awayhome1h_3m ~~                                                            
##    .mother_atpy_1y                                     0.181    0.061    2.984
##  .no2.y1 ~~                                                                   
##    .num_siblings                                      -0.207    0.070   -2.978
##  .father_atopy_1y ~~                                                          
##    .hometype_3m                                       -0.170    0.058   -2.938
##  .mom_UPFContr ~~                                                             
##    .home_plant_3m                                     -1.110    0.378   -2.935
##  .atbx.micro3m ~~                                                             
##    .cndtn_GsttnD__                                     0.282    0.099    2.858
##  .bf.3m ~~                                                                    
##    .home_plant_3m                                      0.040    0.014    2.853
##  .maternaldistress_perceived_pre18w ~~                                        
##    .mom_UPFContr                                       4.606    1.623    2.838
##  .freq_score_basic ~~                                                         
##    .vaginal                                           -1.054    0.379   -2.784
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .no2.y1                                             0.443    0.160    2.767
##  .fasthma ~~                                                                  
##    .floor_carpt_3m                                    -0.157    0.057   -2.761
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .mtrnldstrs__18                                     0.905    0.328    2.757
##  .bf.3m ~~                                                                    
##    .postnatal_smok                                    -0.043    0.016   -2.731
##  .atbx.m.birth ~~                                                             
##    .mom_bmi_best                                       0.600    0.220    2.729
##  .bw_sd ~~                                                                    
##    .hometype_3m                                       -0.097    0.036   -2.723
##  .maternaldistress_perceived_pre18w ~~                                        
##    .winter                                             0.637    0.234    2.717
##  .atbx.micro3m ~~                                                             
##    .vaginal                                           -0.184    0.068   -2.692
##  .atbx.m.birth ~~                                                             
##    .num_siblings                                      -0.088    0.033   -2.673
##  .canue_Zdweldensity_pre18w ~~                                                
##    .mtrnldstrs__18                                    -0.760    0.288   -2.643
##  .cat_1y ~~                                                                   
##    .prenatal_smoke                                     0.167    0.064    2.627
##  .Pregnancy.Tdens250 ~~                                                       
##    .floor_carpt_3m                                    -1.599    0.615   -2.600
##  .maternaldistress_perceived_pre18w ~~                                        
##    .no2.preg                                          -1.485    0.577   -2.575
##  .canue_Zdweldensity_pre18w ~~                                                
##    .dog_1y                                            -0.208    0.082   -2.539
##  .atbx.micro3m ~~                                                             
##    .frntr_dnstyc_3                                     0.194    0.077    2.526
##  .father_atopy_1y ~~                                                          
##    .mtrnldstrs__18                                     0.641    0.256    2.504
##  .awayhome1h_3m ~~                                                            
##    .masthma                                            0.156    0.063    2.496
##  .freq_score_basic ~~                                                         
##    .postnatal_smok                                     1.062    0.428    2.479
##  .atbx.micro3m ~~                                                             
##    .rural                                             -0.324    0.131   -2.478
##  .bw_sd ~~                                                                    
##    .cn_Zdwldnst_18                                    -0.109    0.044   -2.465
##  .masthma ~~                                                                  
##    .mom_UPFContr                                       1.035    0.423    2.449
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .num_siblings                                      -0.156    0.064   -2.446
##  .atbx.m.preg ~~                                                              
##    .mother_atpy_1y                                    -0.146    0.060   -2.446
##  .atbx.m.birth ~~                                                             
##    .gest_days                                         -0.881    0.361   -2.439
##  .cat_1y ~~                                                                   
##    .floor_carpt_3m                                    -0.132    0.054   -2.434
##  .bf.3m ~~                                                                    
##    .awayhome1h_3m                                     -0.040    0.016   -2.422
##  .mother_atopy_1y ~~                                                          
##    .Prgnncy.Tdn250                                    -1.559    0.647   -2.410
##  .bw_sd ~~                                                                    
##    .fall                                              -0.087    0.036   -2.408
##  .furniture_densityclutter_3m ~~                                              
##    .floor_carpt_3m                                    -0.130    0.054   -2.386
##  .freq_score_basic ~~                                                         
##    .hometype_3m                                       -0.933    0.396   -2.356
##  .bf.3m ~~                                                                    
##    .winter                                            -0.034    0.015   -2.343
##  .freq_score_basic ~~                                                         
##    .masthma                                            0.859    0.376    2.283
##  .atbx.m.birth ~~                                                             
##    .cndtn_GsttnD__                                     0.230    0.101    2.279
##  .bf.3m ~~                                                                    
##    .num_siblings                                       0.017    0.008    2.228
##  .cat_1y ~~                                                                   
##    .mould_3m_mh                                        0.148    0.067    2.209
##  .dog_1y ~~                                                                   
##    .postnatal_smok                                     0.136    0.062    2.182
##  .mom_UPFContr ~~                                                             
##    .floor_carpt_3m                                     0.854    0.391    2.182
##  .atbx.m.birth ~~                                                             
##    .no2.preg                                          -0.319    0.148   -2.160
##  .atbx.m.preg ~~                                                              
##    .vaginal                                           -0.132    0.062   -2.132
##  .bw_sd ~~                                                                    
##    .vaginal                                           -0.072    0.034   -2.132
##  .cat_1y ~~                                                                   
##    .cndtn_GsttnD__                                    -0.217    0.103   -2.105
##  .bf.3m ~~                                                                    
##    .mom_UPFContr                                      -0.234    0.111   -2.103
##  .atbx.m.preg ~~                                                              
##    .gest_days                                         -0.782    0.372   -2.101
##  .gest_days ~~                                                                
##    .summer                                             0.772    0.369    2.093
##  .postnatal_smoke ~~                                                          
##    .rural                                              0.181    0.087    2.066
##  .atbx.m.birth ~~                                                             
##    .bw_sd                                              0.089    0.043    2.057
##  .bw_sd ~~                                                                    
##    .Prgnncy.Tdn250                                     0.981    0.481    2.038
##    .floor_carpt_3m                                    -0.070    0.035   -2.020
##    .mother_atpy_1y                                    -0.066    0.033   -1.981
##  .father_atopy_1y ~~                                                          
##    .masthma                                           -0.110    0.056   -1.965
##  .atbx.m.preg ~~                                                              
##    .mom_UPFContr                                       0.972    0.495    1.964
##  .mom_bmi_best ~~                                                             
##    .winter                                             0.365    0.186    1.962
##   P(>|z|)
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.002
##          
##     0.002
##          
##     0.002
##          
##     0.002
##          
##     0.002
##          
##     0.002
##          
##     0.002
##     0.002
##          
##     0.002
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.004
##          
##     0.004
##          
##     0.005
##          
##     0.005
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.007
##          
##     0.007
##          
##     0.008
##          
##     0.008
##          
##     0.009
##          
##     0.009
##          
##     0.010
##          
##     0.011
##          
##     0.012
##          
##     0.012
##          
##     0.013
##          
##     0.013
##          
##     0.013
##          
##     0.014
##          
##     0.014
##          
##     0.014
##          
##     0.014
##          
##     0.015
##          
##     0.015
##          
##     0.015
##          
##     0.016
##          
##     0.016
##          
##     0.017
##          
##     0.018
##          
##     0.019
##          
##     0.022
##          
##     0.023
##          
##     0.026
##          
##     0.027
##          
##     0.029
##          
##     0.029
##          
##     0.031
##          
##     0.033
##          
##     0.033
##          
##     0.035
##          
##     0.035
##          
##     0.036
##          
##     0.036
##          
##     0.039
##          
##     0.040
##          
##     0.042
##     0.043
##     0.048
##          
##     0.049
##          
##     0.050
##          
##     0.050
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .sp.3m.PCoA1       1.730    1.263    1.370    0.171
##    .bf.3m             0.998    0.069   14.508    0.000
##    .bw_sd             0.096    0.111    0.864    0.388
##    .cn_Zdwldnst_18    0.112    0.276    0.406    0.685
##    .freq_score_bsc   31.548    1.033   30.544    0.000
##    .gest_days       280.875    1.066  263.484    0.000
##    .mtrnldstrs__18   12.356    0.663   18.632    0.000
##    .mom_bmi_best     25.569    0.586   43.665    0.000
##    .mom_UPFContr     47.922    1.125   42.588    0.000
##    .no2.preg          4.061    0.440    9.231    0.000
##    .no2.y1            4.467    0.395   11.308    0.000
##    .num_siblings      0.535    0.085    6.274    0.000
##    .Prgnncy.Tdn250   19.279    2.325    8.294    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     atbx.micr3m|t1    1.738    0.213    8.169    0.000
##     atbx.m.brth|t1    0.272    0.185    1.470    0.142
##     atbx.m.preg|t1    0.888    0.190    4.683    0.000
##     awayhm1h_3m|t1    1.510    0.198    7.643    0.000
##     cat_1y|t1         0.373    0.178    2.088    0.037
##     cndtn_GstD__|1    2.439    0.257    9.479    0.000
##     dog_1y|t1         0.397    0.171    2.329    0.020
##     fasthma|t1        0.839    0.170    4.922    0.000
##     fthr_tpy_1y|t1   -0.248    0.165   -1.498    0.134
##     hometype_3m|t1    0.879    0.173    5.089    0.000
##     masthma|t1        0.424    0.153    2.772    0.006
##     mthr_tpy_1y|t1   -0.188    0.142   -1.323    0.186
##     postntl_smk|t1    0.773    0.172    4.496    0.000
##     prenatl_smk|t1    0.945    0.161    5.862    0.000
##     rural|t1          1.653    0.273    6.048    0.000
##     frntr_dnst_3|1    0.680    0.164    4.154    0.000
##     hom_plnt_3m|t1   -0.338    0.141   -2.405    0.016
##     flr_crpt_3m|t1   -0.113    0.141   -0.804    0.421
##     mould_3m_mh|t1    1.353    0.186    7.264    0.000
##     vaginal|t1       -0.975    0.150   -6.486    0.000
##     fall|t1           1.200    0.158    7.617    0.000
##     summer|t1         1.222    0.154    7.937    0.000
##     winter|t1        -0.035    0.138   -0.250    0.803
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .sp.3m.PCoA1       0.770    0.045   17.029    0.000
##    .bf.3m             0.135    0.015    8.825    0.000
##    .atbx.micro3m      1.000                           
##    .atbx.m.birth      1.000                           
##    .atbx.m.preg       1.000                           
##    .awayhome1h_3m     1.000                           
##    .bw_sd             0.864    0.034   25.618    0.000
##    .cn_Zdwldnst_18    2.338    0.065   35.973    0.000
##    .cat_1y            1.000                           
##    .cndtn_GsttnD__    1.000                           
##    .dog_1y            1.000                           
##    .fasthma           1.000                           
##    .father_atpy_1y    1.000                           
##    .freq_score_bsc   93.423    3.865   24.169    0.000
##    .gest_days        85.039    3.136   27.117    0.000
##    .hometype_3m       1.000                           
##    .masthma           1.000                           
##    .mtrnldstrs__18   36.122    1.600   22.577    0.000
##    .mom_bmi_best     23.749    0.811   29.293    0.000
##    .mom_UPFContr    103.946    3.992   26.036    0.000
##    .mother_atpy_1y    1.000                           
##    .no2.preg         10.115    0.258   39.181    0.000
##    .no2.y1            7.711    0.194   39.820    0.000
##    .num_siblings      0.582    0.024   24.161    0.000
##    .postnatal_smok    1.000                           
##    .Prgnncy.Tdn250  234.709    8.394   27.962    0.000
##    .prenatal_smoke    1.000                           
##    .rural             1.000                           
##    .frntr_dnstyc_3    1.000                           
##    .home_plant_3m     1.000                           
##    .floor_carpt_3m    1.000                           
##    .mould_3m_mh       1.000                           
##    .vaginal           1.000                           
##    .fall              1.000                           
##    .summer            1.000                           
##    .winter            1.000                           
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ind_.3.PCA1_.3    0.080    0.019    4.146    0.000
##     ind_.3.PCA1_.3   -0.005    0.011   -0.431    0.666
##     ind_.3.PCA1_..    0.000    0.001    0.097    0.922
##     ind_.3.PCA1_..    0.007    0.010    0.697    0.486
##     in_.3.PCA1_1_3    0.015    0.012    1.293    0.196
##     ind_s.3.PCA1__    0.001    0.001    0.398    0.690
##     i_.3.PCA1__Z_1   -0.001    0.004   -0.280    0.779
##     ind_.3.PCA1__1    0.003    0.009    0.327    0.743
##     i_.3.PCA1__GD_    0.084    0.047    1.794    0.073
##     ind_.3.PCA1__1   -0.000    0.001   -0.034    0.973
##     ind_sp.3.PCA1_    0.000    0.002    0.212    0.832
##     in_.3.PCA1___1   -0.002    0.008   -0.240    0.811
##     ind_.3.PCA1___   -0.001    0.004   -0.231    0.817
##     ind_s.3.PCA1__   -0.013    0.008   -1.569    0.117
##     ind_.3.PCA1__3   -0.005    0.038   -0.141    0.888
##     ind_sp.3.PCA1_    0.001    0.003    0.294    0.769
##     i_.3.PCA1___18   -0.009    0.025   -0.351    0.726
##     ind_.3.PCA1___   -0.031    0.021   -1.478    0.139
##     i_.3.PCA1__UPF   -0.000    0.012   -0.024    0.981
##     in_.3.PCA1___1    0.004    0.005    0.854    0.393
##     ind_.3.PCA1_2.   -0.004    0.007   -0.545    0.585
##     in_.3.PCA1_2.1    0.006    0.009    0.690    0.490
##     ind_s.3.PCA1__   -0.000    0.002   -0.265    0.791
##     ind_s.3.PCA1__    0.024    0.142    0.171    0.865
##     i_.3.PCA1_P.T2   -0.003    0.010   -0.327    0.744
##     ind_s.3.PCA1__   -0.010    0.111   -0.092    0.927
##     ind_sp.3.PCA1_    0.001    0.011    0.053    0.957
##     in_.3.PCA1___3    0.022    0.026    0.858    0.391
##     in_.3.PCA1___3    0.001    0.007    0.078    0.938
##     in_.3.PCA1___3    0.008    0.007    1.160    0.246
##     in_.3.PCA1__3_   -0.004    0.011   -0.335    0.738
##     ind_sp.3.PCA1_    0.000    0.002    0.113    0.910
##     ind_sp.3.PCA1_   -0.001    0.003   -0.377    0.706
##     ind_sp.3.PCA1_   -0.003    0.005   -0.642    0.521
##     ind_sp.3.PCA1_    0.002    0.004    0.473    0.636
used.test <-  "sp.1y.PCoA3 1.1 bf"   
model.all.final <- SEM.RES.ALL[[used.test]][[2]]
kk <- parameterEstimates(model.all.final,standardized = T)
kk.use <- kk[gsub("ind_","",kk$lhs)!=kk$lhs,]
dd <- subset(kk.use, pvalue<0.05)
FIT <- as.data.frame(t(summary(model.all.final, fit.measures=TRUE)$fit[c("cfi","tli","srmr","rmsea")]))
FIT
##         cfi       tli       srmr       rmsea
## 1 0.9978231 0.9974705 0.07704299 0.007759611
dd
##                       lhs op                        rhs                 label
## 478 ind_sp.1y.PCoA3_bf.1y := mrbf.1y*mmsp.1y.PCoA3bf.1y ind_sp.1y.PCoA3_bf.1y
##        est    se      z pvalue ci.lower ci.upper std.lv std.all std.nox
## 478 -0.074 0.036 -2.073  0.038   -0.144   -0.004 -0.074  -0.044  -0.074
kk[kk$lhs=="sp.1y.PCoA3" & kk$pvalue<0.05,c("rhs","std.all","pvalue")]
##             rhs std.all pvalue
## 2         bf.1y  -0.331  0.001
## 8         bw_sd   0.089  0.028
## 351 sp.1y.PCoA3   0.840  0.000
kk[kk$rhs=="MR1_latent.raw" & kk$pvalue<0.05,c("lhs","std.all","pvalue")]
##                                                lhs std.all pvalue
## 44                                           bf.1y   0.132  0.003
## 66                                   awayhome1h_3m  -0.106  0.042
## 82  condition_GestationalDiabetes_mother_prelabour  -0.197  0.003
## 102                                      gest_days   0.127  0.000
## 106                                    hometype_3m  -0.234  0.000
## 114                  maternaldistress_perceived_1y  -0.168  0.000
## 118              maternaldistress_perceived_pre18w  -0.286  0.000
## 122                                   mom_bmi_best  -0.235  0.000
## 126                                   mom_UPFContr  -0.142  0.000
## 146                                postnatal_smoke  -0.367  0.000
## 150                             Pregnancy.Tdens250   0.105  0.000
## 154                                 prenatal_smoke  -0.316  0.000
## 162                    furniture_densityclutter_3m  -0.199  0.000
## 166                                  home_plant_3m   0.126  0.001
## 170                                floor_carpet_3m  -0.084  0.027
## 174                                    mould_3m_mh  -0.119  0.017
## NA                                            <NA>      NA     NA
summary(model.all.final, fit=T)
## lavaan 0.6-19 ended normally after 914 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       378
## 
##                                                   Used       Total
##   Number of observations                          1217        2752
##   Number of missing patterns                       228            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                               649.296     636.782
##   Degrees of freedom                               605         605
##   P-value (Chi-square)                           0.103       0.180
##   Scaling correction factor                                  1.394
##   Shift parameter                                          170.928
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             21051.526   14425.209
##   Degrees of freedom                               703         703
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  1.483
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.998       0.998
##   Tucker-Lewis Index (TLI)                       0.997       0.997
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.008       0.007
##   90 Percent confidence interval - lower         0.000       0.000
##   90 Percent confidence interval - upper         0.012       0.011
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.077       0.077
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Regressions:
##                                                    Estimate  Std.Err  z-value
##   sp.1y.PCoA3 ~                                                              
##                             (dir1)                    0.058    0.154    0.373
##                  (mmsp.1y.PCA3b.1)                   -0.677    0.202   -3.357
##                  (mmsp.1y.PCA3t.1)                    0.069    0.058    1.191
##              (mmsp.1y.PCA3tbx.m.b)                   -0.089    0.061   -1.464
##              (mmsp.1y.PCA3tbx.m.p)                    0.084    0.053    1.586
##                      (m.1.PCA31_1)                   -0.309    0.392   -0.788
##                      (m.1.PCA31_3)                    0.094    0.136    0.687
##                   (mmsp.1y.PCA3b_)                    0.096    0.044    2.195
##                       (m.1.PCA3_Z)                    0.059    0.049    1.210
##                  (mmsp.1y.PCA3c_1)                    0.006    0.065    0.096
##                       (m.1.PCA3_G)                    0.068    0.115    0.591
##                  (mmsp.1y.PCA3d_1)                    0.061    0.072    0.856
##                   (mmsp.1y.PCA3fs)                    0.031    0.068    0.447
##                 (mmsp.1y.PCA3f__1)                   -0.040    0.083   -0.482
##                  (mmsp.1y.PCA3f__)                   -0.005    0.005   -1.048
##                   (mmsp.1y.PCA3g_)                   -0.001    0.004   -0.262
##                      (mm.1.PCA3_3)                    0.029    0.140    0.204
##                    (mmsp.1y.PCA3m)                   -0.007    0.050   -0.140
##               (mmsp.1y.PCA3mtr__1)                    0.029    0.047    0.611
##                     (m.1.PCA3__18)                   -0.014    0.028   -0.504
##                  (mmsp.1y.PCA3m__)                   -0.003    0.009   -0.335
##                       (m.1.PCA3_U)                   -0.001    0.004   -0.273
##               (mmsp.1y.PCA3mth__1)                   -0.016    0.046   -0.348
##                      (mm.1.PCA32.)                   -0.123    0.063   -1.945
##                      (m.1.PCA32.1)                   -0.037    0.095   -0.394
##                   (mmsp.1y.PCA3n_)                   -0.229    0.146   -1.567
##                  (mmsp.1y.PCA3ps_)                   -0.040    0.162   -0.249
##                        (m.1.PCA3P)                   -0.001    0.003   -0.179
##                  (mmsp.1y.PCA3pr_)                    0.057    0.164    0.344
##                    (mmsp.1y.PCA3r)                   -0.262    0.300   -0.871
##                (mmsp.1y.PCA3fr__3)                    0.021    0.092    0.224
##                 (mmsp.1y.PCA3h__3)                    0.045    0.050    0.895
##                (mmsp.1y.PCA3fl__3)                   -0.045    0.075   -0.602
##                      (m.1.PCA3_3_)                   -0.015    0.052   -0.284
##                    (mmsp.1y.PCA3v)                    0.001    0.064    0.020
##                   (mmsp.1y.PCA3fl)                    0.031    0.040    0.782
##                    (mmsp.1y.PCA3s)                    0.037    0.040    0.936
##                    (mmsp.1y.PCA3w)                   -0.081    0.054   -1.495
##                                                       0.368    0.310    1.189
##                                                       1.082    0.898    1.206
##                                                       1.497    1.073    1.395
##                                                       0.002    0.002    0.889
##                                                      -0.306    0.367   -0.834
##   bf.1y ~                                                                    
##                            (mrb.1)                    0.109    0.037    2.979
##                                                       0.094    0.043    2.161
##                                                      -0.094    0.048   -1.969
##                                                      -0.104    0.046   -2.258
##                                                      -0.934    0.254   -3.685
##   atbx.micro1y ~                                                             
##                            (mrt.1)                   -0.061    0.082   -0.746
##                                                      -0.182    0.124   -1.469
##                                                      -0.067    0.127   -0.529
##                                                      -0.102    0.128   -0.798
##                                                       0.924    0.434    2.125
##   atbx.m.birth ~                                                             
##                        (mrtbx.m.b)                   -0.016    0.084   -0.187
##                                                       0.289    0.124    2.334
##                                                      -0.069    0.138   -0.498
##                                                       0.107    0.134    0.795
##   atbx.m.preg ~                                                              
##                        (mrtbx.m.p)                   -0.089    0.094   -0.948
##                                                      -0.152    0.133   -1.143
##                                                      -0.239    0.146   -1.642
##                                                      -0.133    0.139   -0.960
##   awayhome1h_1y ~                                                            
##                             (m1_1)                   -0.001    0.076   -0.009
##                                                      -0.136    0.115   -1.179
##                                                       0.017    0.119    0.146
##                                                       0.047    0.120    0.390
##   awayhome1h_3m ~                                                            
##                             (m1_3)                   -0.180    0.089   -2.030
##                                                      -0.035    0.146   -0.239
##                                                      -0.008    0.147   -0.055
##                                                       0.148    0.143    1.029
##   bw_sd ~                                                                    
##                             (mrb_)                   -0.054    0.052   -1.024
##                                                      -0.005    0.078   -0.061
##                                                      -0.106    0.079   -1.340
##                                                      -0.168    0.083   -2.035
##   canue_Zdweldensity_pre18w ~                                                
##                             (m_Z_)                    0.105    0.095    1.107
##                                                       1.800    0.239    7.536
##                                                      -0.082    0.466   -0.176
##                                                       2.068    0.241    8.585
##   cat_1y ~                                                                   
##                            (mrc_1)                   -0.035    0.078   -0.450
##                                                      -0.056    0.119   -0.476
##                                                      -0.021    0.124   -0.171
##                                                      -0.232    0.136   -1.705
##   condition_GestationalDiabetes_mother_prelabour ~                           
##                             (m_GD)                   -0.340    0.116   -2.939
##                                                       0.392    0.194    2.026
##                                                       0.398    0.215    1.850
##                                                       0.404    0.214    1.894
##   dog_1y ~                                                                   
##                            (mrd_1)                   -0.019    0.081   -0.239
##                                                      -0.531    0.121   -4.387
##                                                      -0.021    0.117   -0.178
##                                                      -0.341    0.122   -2.787
##   fasthma ~                                                                  
##                             (mrfs)                   -0.045    0.085   -0.531
##                                                       0.122    0.122    0.998
##                                                       0.217    0.146    1.487
##                                                      -0.075    0.129   -0.581
##   father_atopy_1y ~                                                          
##                           (mrf__1)                    0.127    0.081    1.569
##                                                       0.254    0.114    2.225
##                                                       0.244    0.139    1.752
##                                                       0.360    0.117    3.075
##   freq_score_basic ~                                                         
##                            (mrf__)                    0.139    0.530    0.262
##                                                      -2.670    0.817   -3.270
##                                                       0.769    0.897    0.857
##                                                       2.054    0.780    2.634
##   gest_days ~                                                                
##                             (mrg_)                    1.993    0.492    4.049
##                                                      -2.492    0.721   -3.458
##                                                      -2.086    0.781   -2.670
##                                                      -2.602    0.795   -3.271
##   hometype_3m ~                                                              
##                             (mr_3)                   -0.463    0.076   -6.064
##                                                       1.461    0.121   12.085
##                                                      -0.095    0.149   -0.635
##                                                       0.900    0.129    6.990
##   masthma ~                                                                  
##                             (mrms)                    0.045    0.075    0.603
##                                                      -0.187    0.114   -1.631
##                                                      -0.008    0.118   -0.069
##                                                      -0.009    0.116   -0.077
##   maternaldistress_perceived_1y ~                                            
##                         (mrmtr__1)                   -1.838    0.359   -5.119
##                                                      -0.161    0.542   -0.298
##                                                      -0.628    0.602   -1.044
##                                                       0.556    0.552    1.007
##   maternaldistress_perceived_pre18w ~                                        
##                            (m__18)                   -2.990    0.324   -9.231
##                                                       0.646    0.491    1.316
##                                                       0.823    0.560    1.469
##                                                       1.082    0.508    2.131
##   mom_bmi_best ~                                                             
##                            (mrm__)                   -2.029    0.257   -7.909
##                                                      -1.106    0.433   -2.552
##                                                       0.052    0.411    0.126
##                                                      -0.479    0.433   -1.106
##   mom_UPFContr ~                                                             
##                             (m_UP)                   -2.477    0.521   -4.753
##                                                      -2.884    0.856   -3.369
##                                                      -1.487    0.866   -1.718
##                                                      -0.330    0.833   -0.396
##   mother_atopy_1y ~                                                          
##                         (mrmth__1)                    0.090    0.068    1.333
##                                                       0.446    0.104    4.304
##                                                       0.377    0.111    3.402
##                                                       0.413    0.107    3.851
##   no2.preg ~                                                                 
##                             (mr2.)                    0.286    0.190    1.504
##                                                       7.302    0.367   19.907
##                                                       7.558    0.366   20.666
##                                                      12.450    0.353   35.237
##   no2.y1 ~                                                                   
##                             (m2.1)                    0.236    0.161    1.467
##                                                       5.639    0.320   17.642
##                                                       6.657    0.324   20.518
##                                                      10.945    0.306   35.763
##   num_siblings ~                                                             
##                             (mrn_)                   -0.004    0.039   -0.103
##                                                      -0.198    0.064   -3.075
##                                                      -0.063    0.065   -0.967
##                                                      -0.338    0.066   -5.096
##   postnatal_smoke ~                                                          
##                            (mrps_)                   -0.677    0.084   -8.059
##                                                      -0.202    0.128   -1.576
##                                                       0.043    0.126    0.343
##                                                      -0.080    0.138   -0.579
##   Pregnancy.Tdens250 ~                                                       
##                             (mP.T)                    3.802    0.992    3.835
##                                                       2.082    2.441    0.853
##                                                      -6.656    2.874   -2.316
##                                                      31.443    2.020   15.567
##   prenatal_smoke ~                                                           
##                            (mrpr_)                   -0.578    0.078   -7.370
##                                                      -0.404    0.127   -3.186
##                                                      -0.088    0.124   -0.714
##                                                      -0.136    0.125   -1.083
##   rural ~                                                                    
##                             (mrrr)                   -0.092    0.135   -0.681
##                                                      -1.557    0.356   -4.377
##                                                      -0.646    0.183   -3.529
##                                                      -1.045    0.230   -4.548
##   furniture_densityclutter_3m ~                                              
##                          (mrfr__3)                   -0.349    0.079   -4.437
##                                                      -0.282    0.121   -2.327
##                                                      -0.308    0.132   -2.338
##                                                      -0.217    0.126   -1.723
##   home_plant_3m ~                                                            
##                           (mrh__3)                    0.220    0.069    3.185
##                                                       0.545    0.107    5.108
##                                                       0.149    0.112    1.326
##                                                       0.102    0.106    0.963
##   floor_carpet_3m ~                                                          
##                          (mrfl__3)                   -0.155    0.070   -2.217
##                                                       0.011    0.103    0.104
##                                                       0.488    0.118    4.134
##                                                      -0.669    0.108   -6.189
##   mould_3m_mh ~                                                              
##                             (m_3_)                   -0.210    0.088   -2.378
##                                                       0.258    0.130    1.981
##                                                      -0.409    0.181   -2.255
##                                                       0.480    0.140    3.431
##   vaginal ~                                                                  
##                             (mrvg)                   -0.020    0.075   -0.265
##                                                      -0.131    0.113   -1.157
##                                                      -0.096    0.121   -0.795
##                                                      -0.370    0.113   -3.284
##   fall ~                                                                     
##                             (mrfl)                   -0.038    0.076   -0.499
##                                                       0.236    0.110    2.156
##                                                       0.150    0.120    1.250
##                                                       0.080    0.117    0.683
##   summer ~                                                                   
##                             (mrsm)                   -0.119    0.071   -1.670
##                                                       0.202    0.108    1.873
##                                                       0.047    0.118    0.400
##                                                      -0.108    0.117   -0.926
##   winter ~                                                                   
##                             (mrwn)                   -0.070    0.075   -0.935
##                                                      -0.071    0.117   -0.607
##                                                       0.028    0.120    0.228
##                                                       0.109    0.117    0.934
##   P(>|z|)
##          
##     0.709
##     0.001
##     0.234
##     0.143
##     0.113
##     0.431
##     0.492
##     0.028
##     0.226
##     0.924
##     0.555
##     0.392
##     0.655
##     0.630
##     0.295
##     0.793
##     0.838
##     0.889
##     0.541
##     0.614
##     0.738
##     0.785
##     0.728
##     0.052
##     0.694
##     0.117
##     0.803
##     0.858
##     0.731
##     0.384
##     0.822
##     0.371
##     0.547
##     0.776
##     0.984
##     0.434
##     0.350
##     0.135
##     0.234
##     0.228
##     0.163
##     0.374
##     0.404
##          
##     0.003
##     0.031
##     0.049
##     0.024
##     0.000
##          
##     0.456
##     0.142
##     0.597
##     0.425
##     0.034
##          
##     0.852
##     0.020
##     0.618
##     0.427
##          
##     0.343
##     0.253
##     0.101
##     0.337
##          
##     0.993
##     0.238
##     0.884
##     0.696
##          
##     0.042
##     0.811
##     0.956
##     0.304
##          
##     0.306
##     0.952
##     0.180
##     0.042
##          
##     0.268
##     0.000
##     0.860
##     0.000
##          
##     0.653
##     0.634
##     0.865
##     0.088
##          
##     0.003
##     0.043
##     0.064
##     0.058
##          
##     0.811
##     0.000
##     0.859
##     0.005
##          
##     0.595
##     0.318
##     0.137
##     0.561
##          
##     0.117
##     0.026
##     0.080
##     0.002
##          
##     0.793
##     0.001
##     0.392
##     0.008
##          
##     0.000
##     0.001
##     0.008
##     0.001
##          
##     0.000
##     0.000
##     0.525
##     0.000
##          
##     0.546
##     0.103
##     0.945
##     0.939
##          
##     0.000
##     0.766
##     0.297
##     0.314
##          
##     0.000
##     0.188
##     0.142
##     0.033
##          
##     0.000
##     0.011
##     0.900
##     0.269
##          
##     0.000
##     0.001
##     0.086
##     0.692
##          
##     0.182
##     0.000
##     0.001
##     0.000
##          
##     0.133
##     0.000
##     0.000
##     0.000
##          
##     0.142
##     0.000
##     0.000
##     0.000
##          
##     0.918
##     0.002
##     0.333
##     0.000
##          
##     0.000
##     0.115
##     0.731
##     0.563
##          
##     0.000
##     0.394
##     0.021
##     0.000
##          
##     0.000
##     0.001
##     0.475
##     0.279
##          
##     0.496
##     0.000
##     0.000
##     0.000
##          
##     0.000
##     0.020
##     0.019
##     0.085
##          
##     0.001
##     0.000
##     0.185
##     0.336
##          
##     0.027
##     0.917
##     0.000
##     0.000
##          
##     0.017
##     0.048
##     0.024
##     0.001
##          
##     0.791
##     0.247
##     0.427
##     0.001
##          
##     0.618
##     0.031
##     0.211
##     0.495
##          
##     0.095
##     0.061
##     0.689
##     0.355
##          
##     0.350
##     0.544
##     0.819
##     0.350
## 
## Covariances:
##                                                     Estimate  Std.Err  z-value
##  .no2.y1 ~~                                                                   
##    .rural                                             -2.782    0.035  -78.793
##  .no2.preg ~~                                                                 
##    .rural                                             -3.134    0.040  -78.321
##  .awayhome1h_1y ~~                                                            
##    .mtrnldstrss__1                                     6.359    0.145   43.790
##  .no2.preg ~~                                                                 
##    .no2.y1                                             6.862    0.195   35.125
##  .canue_Zdweldensity_pre18w ~~                                                
##    .no2.preg                                           2.774    0.093   29.933
##  .postnatal_smoke ~~                                                          
##    .prenatal_smoke                                     0.810    0.028   28.459
##  .canue_Zdweldensity_pre18w ~~                                                
##    .no2.y1                                             1.790    0.073   24.445
##  .maternaldistress_perceived_1y ~~                                            
##    .rural                                             -3.613    0.165  -21.891
##  .canue_Zdweldensity_pre18w ~~                                                
##    .hometype_3m                                        0.701    0.032   21.620
##  .maternaldistress_perceived_1y ~~                                            
##    .mtrnldstrs__18                                    16.861    1.211   13.926
##  .hometype_3m ~~                                                              
##    .no2.preg                                           1.130    0.112   10.103
##    .no2.y1                                             0.805    0.092    8.754
##  .fasthma ~~                                                                  
##    .father_atpy_1y                                     0.440    0.058    7.573
##  .masthma ~~                                                                  
##    .mother_atpy_1y                                     0.314    0.047    6.687
##  .hometype_3m ~~                                                              
##    .num_siblings                                      -0.199    0.030   -6.637
##  .bw_sd ~~                                                                    
##    .mom_bmi_best                                       0.792    0.125    6.311
##  .awayhome1h_1y ~~                                                            
##    .num_siblings                                      -0.176    0.032   -5.565
##  .dog_1y ~~                                                                   
##    .freq_score_bsc                                     2.170    0.411    5.283
##  .furniture_densityclutter_3m ~~                                              
##    .mould_3m_mh                                        0.315    0.061    5.123
##  .dog_1y ~~                                                                   
##    .hometype_3m                                       -0.294    0.058   -5.044
##  .awayhome1h_1y ~~                                                            
##    .awayhome1h_3m                                      0.312    0.062    5.029
##  .canue_Zdweldensity_pre18w ~~                                                
##    .rural                                             -0.520    0.106   -4.911
##  .num_siblings ~~                                                             
##    .prenatal_smoke                                    -0.129    0.027   -4.770
##  .bw_sd ~~                                                                    
##    .num_siblings                                       0.096    0.020    4.687
##  .no2.preg ~~                                                                 
##    .num_siblings                                      -0.363    0.079   -4.594
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .mom_bmi_best                                       1.193    0.263    4.543
##  .canue_Zdweldensity_pre18w ~~                                                
##    .num_siblings                                      -0.179    0.040   -4.516
##  .no2.y1 ~~                                                                   
##    .floor_carpt_3m                                    -0.461    0.103   -4.492
##  .no2.preg ~~                                                                 
##    .winter                                            -0.586    0.131   -4.475
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .gest_days                                         -2.177    0.499   -4.367
##  .freq_score_basic ~~                                                         
##    .mom_UPFContr                                      11.761    2.729    4.309
##  .hometype_3m ~~                                                              
##    .frntr_dnstyc_3                                     0.237    0.056    4.214
##  .freq_score_basic ~~                                                         
##    .mom_bmi_best                                       5.492    1.380    3.980
##  .gest_days ~~                                                                
##    .num_siblings                                      -0.809    0.204   -3.969
##  .mom_UPFContr ~~                                                             
##    .postnatal_smok                                     1.781    0.450    3.955
##  .cat_1y ~~                                                                   
##    .frntr_dnstyc_3                                     0.235    0.060    3.909
##  .no2.y1 ~~                                                                   
##    .frntr_dnstyc_3                                     0.467    0.122    3.837
##  .mom_bmi_best ~~                                                             
##    .vaginal                                           -0.685    0.179   -3.828
##  .no2.preg ~~                                                                 
##    .frntr_dnstyc_3                                     0.515    0.135    3.805
##  .num_siblings ~~                                                             
##    .postnatal_smok                                    -0.110    0.029   -3.777
##  .no2.preg ~~                                                                 
##    .floor_carpt_3m                                    -0.411    0.112   -3.670
##  .no2.y1 ~~                                                                   
##    .Prgnncy.Tdn250                                     2.791    0.761    3.666
##  .mom_bmi_best ~~                                                             
##    .mom_UPFContr                                       5.109    1.394    3.664
##  .hometype_3m ~~                                                              
##    .Prgnncy.Tdn250                                    -2.025    0.567   -3.573
##  .bf.1y ~~                                                                    
##    .freq_score_bsc                                    -0.910    0.255   -3.564
##  .num_siblings ~~                                                             
##    .vaginal                                            0.101    0.029    3.507
##  .freq_score_basic ~~                                                         
##    .prenatal_smoke                                     1.346    0.386    3.488
##  .masthma ~~                                                                  
##    .mom_bmi_best                                       0.619    0.182    3.403
##  .no2.y1 ~~                                                                   
##    .num_siblings                                      -0.234    0.070   -3.339
##  .freq_score_basic ~~                                                         
##    .no2.y1                                            -2.370    0.711   -3.335
##  .dog_1y ~~                                                                   
##    .num_siblings                                      -0.102    0.031   -3.328
##  .cat_1y ~~                                                                   
##    .Prgnncy.Tdn250                                     2.757    0.838    3.290
##  .maternaldistress_perceived_1y ~~                                            
##    .frntr_dnstyc_3                                     0.874    0.272    3.215
##  .gest_days ~~                                                                
##    .vaginal                                            1.097    0.344    3.188
##  .freq_score_basic ~~                                                         
##    .postnatal_smok                                     1.354    0.427    3.171
##  .hometype_3m ~~                                                              
##    .winter                                             0.171    0.055    3.131
##  .canue_Zdweldensity_pre18w ~~                                                
##    .dog_1y                                            -0.267    0.085   -3.130
##  .freq_score_basic ~~                                                         
##    .frntr_dnstyc_3                                    -1.214    0.390   -3.111
##    .vaginal                                           -1.145    0.375   -3.056
##  .atbx.micro1y ~~                                                             
##    .num_siblings                                       0.095    0.031    3.045
##  .awayhome1h_3m ~~                                                            
##    .cn_Zdwldnst_18                                     0.191    0.064    2.986
##  .mom_bmi_best ~~                                                             
##    .home_plant_3m                                     -0.539    0.181   -2.977
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .mtrnldstrs__18                                     0.985    0.334    2.949
##  .maternaldistress_perceived_pre18w ~~                                        
##    .prenatal_smoke                                     0.759    0.257    2.948
##  .father_atopy_1y ~~                                                          
##    .hometype_3m                                       -0.171    0.058   -2.933
##  .maternaldistress_perceived_pre18w ~~                                        
##    .mom_UPFContr                                       4.552    1.568    2.903
##  .masthma ~~                                                                  
##    .mtrnldstrs__18                                     0.684    0.236    2.900
##  .cat_1y ~~                                                                   
##    .postnatal_smok                                     0.185    0.064    2.897
##    .prenatal_smoke                                     0.181    0.063    2.868
##  .mom_bmi_best ~~                                                             
##    .frntr_dnstyc_3                                     0.556    0.194    2.861
##  .freq_score_basic ~~                                                         
##    .mtrnldstrs__18                                     4.566    1.623    2.813
##  .maternaldistress_perceived_pre18w ~~                                        
##    .mom_bmi_best                                       2.419    0.872    2.774
##  .awayhome1h_3m ~~                                                            
##    .mother_atpy_1y                                     0.167    0.060    2.756
##  .bf.1y ~~                                                                    
##    .mom_UPFContr                                      -0.501    0.182   -2.754
##  .bw_sd ~~                                                                    
##    .hometype_3m                                       -0.096    0.035   -2.738
##  .fasthma ~~                                                                  
##    .floor_carpt_3m                                    -0.155    0.057   -2.726
##  .masthma ~~                                                                  
##    .mom_UPFContr                                       1.115    0.411    2.716
##  .bf.1y ~~                                                                    
##    .mom_bmi_best                                      -0.242    0.089   -2.707
##  .atbx.m.birth ~~                                                             
##    .mom_bmi_best                                       0.584    0.219    2.669
##  .mom_UPFContr ~~                                                             
##    .home_plant_3m                                     -1.010    0.380   -2.660
##  .canue_Zdweldensity_pre18w ~~                                                
##    .summer                                            -0.138    0.052   -2.658
##  .father_atopy_1y ~~                                                          
##    .mtrnldstrs__18                                     0.669    0.253    2.647
##  .dog_1y ~~                                                                   
##    .postnatal_smok                                     0.162    0.061    2.641
##  .atbx.micro1y ~~                                                             
##    .cndtn_GsttnD__                                     0.225    0.085    2.639
##  .maternaldistress_perceived_pre18w ~~                                        
##    .winter                                             0.604    0.230    2.628
##  .bw_sd ~~                                                                    
##    .cn_Zdwldnst_18                                    -0.114    0.044   -2.590
##  .atbx.micro1y ~~                                                             
##    .freq_score_bsc                                     1.067    0.413    2.583
##  .canue_Zdweldensity_pre18w ~~                                                
##    .mtrnldstrs__18                                    -0.721    0.280   -2.576
##  .atbx.micro1y ~~                                                             
##    .atbx.m.preg                                        0.170    0.066    2.573
##    .mom_bmi_best                                       0.502    0.195    2.569
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .no2.y1                                             0.428    0.167    2.563
##  .atbx.m.birth ~~                                                             
##    .num_siblings                                      -0.082    0.032   -2.539
##  .awayhome1h_3m ~~                                                            
##    .masthma                                            0.156    0.063    2.486
##  .Pregnancy.Tdens250 ~~                                                       
##    .floor_carpt_3m                                    -1.518    0.614   -2.470
##  .mother_atopy_1y ~~                                                          
##    .Prgnncy.Tdn250                                    -1.584    0.644   -2.459
##  .cat_1y ~~                                                                   
##    .floor_carpt_3m                                    -0.132    0.054   -2.455
##  .bf.1y ~~                                                                    
##    .atbx.micro1y                                      -0.059    0.024   -2.436
##    .prenatal_smoke                                    -0.058    0.024   -2.410
##  .atbx.m.preg ~~                                                              
##    .mother_atpy_1y                                    -0.137    0.058   -2.349
##  .cat_1y ~~                                                                   
##    .cndtn_GsttnD__                                    -0.228    0.097   -2.347
##  .freq_score_basic ~~                                                         
##    .hometype_3m                                       -0.929    0.399   -2.331
##  .maternaldistress_perceived_pre18w ~~                                        
##    .no2.preg                                          -1.302    0.562   -2.318
##  .bw_sd ~~                                                                    
##    .fall                                              -0.083    0.036   -2.308
##  .bf.1y ~~                                                                    
##    .postnatal_smok                                    -0.058    0.025   -2.295
##  .maternaldistress_perceived_1y ~~                                            
##    .home_plant_3m                                     -0.562    0.245   -2.295
##  .freq_score_basic ~~                                                         
##    .masthma                                            0.860    0.376    2.291
##  .bf.1y ~~                                                                    
##    .home_plant_3m                                      0.047    0.021    2.288
##  .atbx.m.birth ~~                                                             
##    .gest_days                                         -0.805    0.353   -2.282
##  .hometype_3m ~~                                                              
##    .prenatal_smoke                                     0.134    0.059    2.259
##  .atbx.m.birth ~~                                                             
##    .no2.preg                                          -0.327    0.145   -2.255
##  .freq_score_basic ~~                                                         
##    .Prgnncy.Tdn250                                   -10.032    4.459   -2.250
##  .awayhome1h_3m ~~                                                            
##    .winter                                            -0.148    0.066   -2.243
##  .awayhome1h_1y ~~                                                            
##    .vaginal                                           -0.123    0.055   -2.242
##  .atbx.m.preg ~~                                                              
##    .freq_score_bsc                                     1.009    0.452    2.233
##  .awayhome1h_1y ~~                                                            
##    .prenatal_smoke                                     0.134    0.060    2.223
##  .cat_1y ~~                                                                   
##    .mould_3m_mh                                        0.148    0.067    2.200
##  .fasthma ~~                                                                  
##    .mom_bmi_best                                       0.471    0.216    2.185
##  .bw_sd ~~                                                                    
##    .Prgnncy.Tdn250                                     1.015    0.465    2.184
##  .awayhome1h_1y ~~                                                            
##    .frntr_dnstyc_3                                     0.130    0.059    2.179
##    .no2.preg                                           0.281    0.130    2.157
##    .mother_atpy_1y                                     0.109    0.051    2.123
##  .furniture_densityclutter_3m ~~                                              
##    .floor_carpt_3m                                    -0.116    0.055   -2.119
##  .father_atopy_1y ~~                                                          
##    .masthma                                           -0.117    0.056   -2.111
##  .mom_bmi_best ~~                                                             
##    .summer                                            -0.414    0.197   -2.103
##  .home_plant_3m ~~                                                            
##    .floor_carpt_3m                                    -0.100    0.048   -2.090
##  .condition_GestationalDiabetes_mother_prelabour ~~                           
##    .num_siblings                                      -0.127    0.061   -2.085
##  .bf.1y ~~                                                                    
##    .awayhome1h_1y                                     -0.045    0.022   -2.081
##    .rural                                             -0.063    0.031   -2.030
##  .cat_1y ~~                                                                   
##    .gest_days                                          0.784    0.393    1.996
##  .dog_1y ~~                                                                   
##    .gest_days                                          0.764    0.384    1.989
##  .postnatal_smoke ~~                                                          
##    .rural                                              0.176    0.089    1.984
##  .maternaldistress_perceived_1y ~~                                            
##    .mother_atpy_1y                                     0.496    0.251    1.979
##  .atbx.micro1y ~~                                                             
##    .gest_days                                         -0.700    0.357   -1.963
##   P(>|z|)
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.000
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.001
##          
##     0.002
##          
##     0.002
##          
##     0.002
##          
##     0.002
##     0.002
##          
##     0.002
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.003
##          
##     0.004
##          
##     0.004
##          
##     0.004
##     0.004
##          
##     0.004
##          
##     0.005
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.006
##          
##     0.007
##          
##     0.007
##          
##     0.008
##          
##     0.008
##          
##     0.008
##          
##     0.008
##          
##     0.008
##          
##     0.008
##          
##     0.009
##          
##     0.010
##          
##     0.010
##          
##     0.010
##          
##     0.010
##     0.010
##          
##     0.010
##          
##     0.011
##          
##     0.013
##          
##     0.013
##          
##     0.014
##          
##     0.014
##          
##     0.015
##     0.016
##          
##     0.019
##          
##     0.019
##          
##     0.020
##          
##     0.020
##          
##     0.021
##          
##     0.022
##          
##     0.022
##          
##     0.022
##          
##     0.022
##          
##     0.023
##          
##     0.024
##          
##     0.024
##          
##     0.024
##          
##     0.025
##          
##     0.025
##          
##     0.026
##          
##     0.026
##          
##     0.028
##          
##     0.029
##          
##     0.029
##          
##     0.029
##     0.031
##     0.034
##          
##     0.034
##          
##     0.035
##          
##     0.035
##          
##     0.037
##          
##     0.037
##          
##     0.037
##     0.042
##          
##     0.046
##          
##     0.047
##          
##     0.047
##          
##     0.048
##          
##     0.050
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .sp.1y.PCoA3       1.172    1.197    0.979    0.327
##    .bf.1y             1.340    0.237    5.663    0.000
##    .bw_sd             0.347    0.274    1.266    0.205
##    .cn_Zdwldnst_18    0.181    0.474    0.383    0.702
##    .freq_score_bsc   32.494    2.636   12.326    0.000
##    .gest_days       277.831    2.689  103.323    0.000
##    .mtrnldstrss__1   11.330    1.944    5.829    0.000
##    .mtrnldstrs__18   11.809    1.745    6.767    0.000
##    .mom_bmi_best     27.577    1.385   19.913    0.000
##    .mom_UPFContr     48.816    2.821   17.302    0.000
##    .no2.preg          0.747    0.888    0.841    0.400
##    .no2.y1            3.807    0.871    4.369    0.000
##    .num_siblings     -0.042    0.208   -0.203    0.839
##    .Prgnncy.Tdn250   20.873    3.977    5.249    0.000
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     atbx.micr1y|t1    1.503    0.444    3.388    0.001
##     atbx.m.brth|t1    0.279    0.429    0.651    0.515
##     atbx.m.preg|t1    0.506    0.523    0.968    0.333
##     awayhm1h_1y|t1    2.446    0.406    6.020    0.000
##     awayhm1h_3m|t1    1.935    0.500    3.873    0.000
##     cat_1y|t1         1.053    0.417    2.526    0.012
##     cndtn_GstD__|1    1.520    0.829    1.834    0.067
##     dog_1y|t1         0.057    0.430    0.133    0.894
##     fasthma|t1        0.248    0.456    0.544    0.586
##     fthr_tpy_1y|t1   -0.651    0.410   -1.590    0.112
##     hometype_3m|t1    0.881    0.395    2.232    0.026
##     masthma|t1        1.048    0.382    2.746    0.006
##     mthr_tpy_1y|t1   -0.183    0.371   -0.494    0.621
##     postntl_smk|t1    1.036    0.430    2.411    0.016
##     prenatl_smk|t1    0.209    0.392    0.534    0.594
##     rural|t1          2.693    0.595    4.529    0.000
##     frntr_dnst_3|1    0.348    0.421    0.827    0.408
##     hom_plnt_3m|t1   -0.408    0.363   -1.126    0.260
##     flr_crpt_3m|t1    0.268    0.373    0.717    0.474
##     mould_3m_mh|t1    0.490    0.437    1.121    0.262
##     vaginal|t1       -0.303    0.402   -0.753    0.451
##     fall|t1           0.501    0.381    1.313    0.189
##     summer|t1         1.164    0.387    3.008    0.003
##     winter|t1        -0.278    0.402   -0.691    0.489
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .sp.1y.PCoA3       0.839    0.065   12.949    0.000
##    .bf.1y             0.217    0.054    3.998    0.000
##    .atbx.micro1y      1.000                           
##    .atbx.m.birth      1.000                           
##    .atbx.m.preg       1.000                           
##    .awayhome1h_1y     1.000                           
##    .awayhome1h_3m     1.000                           
##    .bw_sd             0.867    0.034   25.564    0.000
##    .cn_Zdwldnst_18    2.275    0.063   36.389    0.000
##    .cat_1y            1.000                           
##    .cndtn_GsttnD__    1.000                           
##    .dog_1y            1.000                           
##    .fasthma           1.000                           
##    .father_atpy_1y    1.000                           
##    .freq_score_bsc   93.066    3.868   24.058    0.000
##    .gest_days        84.378    3.137   26.902    0.000
##    .hometype_3m       1.000                           
##    .masthma           1.000                           
##    .mtrnldstrss__1   40.847    1.847   22.121    0.000
##    .mtrnldstrs__18   35.320    1.546   22.850    0.000
##    .mom_bmi_best     24.007    0.813   29.536    0.000
##    .mom_UPFContr    101.605    3.974   25.568    0.000
##    .mother_atpy_1y    1.000                           
##    .no2.preg          9.923    0.255   38.860    0.000
##    .no2.y1            7.820    0.201   38.944    0.000
##    .num_siblings      0.580    0.024   23.917    0.000
##    .postnatal_smok    1.000                           
##    .Prgnncy.Tdn250  225.598    7.858   28.710    0.000
##    .prenatal_smoke    1.000                           
##    .rural             1.000                           
##    .frntr_dnstyc_3    1.000                           
##    .home_plant_3m     1.000                           
##    .floor_carpt_3m    1.000                           
##    .mould_3m_mh       1.000                           
##    .vaginal           1.000                           
##    .fall              1.000                           
##    .summer            1.000                           
##    .winter            1.000                           
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)
##     ind_.1.PCA3_.1   -0.074    0.036   -2.073    0.038
##     ind_.1.PCA3_.1   -0.004    0.007   -0.624    0.533
##     ind_.1.PCA3_..    0.001    0.008    0.185    0.853
##     ind_.1.PCA3_..   -0.007    0.009   -0.816    0.415
##     in_.1.PCA3_1_1    0.000    0.024    0.009    0.993
##     in_.1.PCA3_1_3   -0.017    0.026   -0.650    0.516
##     ind_s.1.PCA3__   -0.005    0.006   -0.928    0.354
##     i_.1.PCA3__Z_1    0.006    0.007    0.849    0.396
##     ind_.1.PCA3__1   -0.000    0.002   -0.094    0.925
##     i_.1.PCA3__GD_   -0.023    0.040   -0.578    0.564
##     ind_.1.PCA3__1   -0.001    0.005   -0.233    0.816
##     ind_sp.1.PCA3_   -0.001    0.004   -0.343    0.731
##     in_.1.PCA3___1   -0.005    0.011   -0.461    0.645
##     ind_.1.PCA3___   -0.001    0.003   -0.253    0.800
##     ind_s.1.PCA3__   -0.002    0.009   -0.262    0.793
##     ind_.1.PCA3__3   -0.013    0.065   -0.204    0.839
##     ind_sp.1.PCA3_   -0.000    0.002   -0.137    0.891
##     in_.1.PCA3___1   -0.053    0.086   -0.608    0.543
##     i_.1.PCA3___18    0.042    0.084    0.503    0.615
##     ind_.1.PCA3___    0.006    0.019    0.334    0.738
##     i_.1.PCA3__UPF    0.003    0.010    0.272    0.786
##     in_.1.PCA3___1   -0.001    0.004   -0.337    0.736
##     ind_.1.PCA3_2.   -0.035    0.029   -1.213    0.225
##     in_.1.PCA3_2.1   -0.009    0.023   -0.383    0.702
##     ind_s.1.PCA3__    0.001    0.009    0.103    0.918
##     ind_s.1.PCA3__    0.027    0.109    0.250    0.803
##     i_.1.PCA3_P.T2   -0.002    0.011   -0.179    0.858
##     ind_s.1.PCA3__   -0.033    0.095   -0.343    0.731
##     ind_sp.1.PCA3_    0.024    0.045    0.530    0.596
##     in_.1.PCA3___3   -0.007    0.032   -0.224    0.822
##     in_.1.PCA3___3    0.010    0.011    0.864    0.388
##     in_.1.PCA3___3    0.007    0.012    0.573    0.567
##     in_.1.PCA3__3_    0.003    0.011    0.281    0.779
##     ind_sp.1.PCA3_   -0.000    0.001   -0.020    0.984
##     ind_sp.1.PCA3_   -0.001    0.003   -0.420    0.674
##     ind_sp.1.PCA3_   -0.004    0.005   -0.816    0.415
##     ind_sp.1.PCA3_    0.006    0.007    0.797    0.425

Generate dispersion boxplot (Figure 3A)

pdf("Figures/Dispersion figure.pdf",width=3,height=10)
data.withmissing.bf <- merge(data.withmissing,subset(data.div, Visit=="3 month"),by.x="subjectnumber", by.y="SubjectNumber")
data.withmissing.bf$bf <- ifelse(data.withmissing.bf$exact_age*12<data.withmissing.bf$bf_duration_imp,1, 0)
nobf.id <- unique(data.withmissing.bf$subjectnumber[data.withmissing.bf$bf==0 & !is.na(data.withmissing.bf$bf) &  data.withmissing.bf$bf_duration_imp<3])

data.add.bf <-  (varespec.bray.use$`3 month_Species`[[2]])
data.add.bf$bf <- ifelse(data.add.bf$exact_age*12<data.add.bf$bf_duration_imp,1,
                         ifelse(data.add.bf$subjectnumber%in%as.character(nobf.id),0,NA))

bd <- vegan::betadisper(varespec.bray.use$`3 month_Species`[[1]], data.add.bf$bf)
boxplot(bd)
df <- data.frame(Distance_to_centroid=bd$distances,Group=bd$group)
groups <- bd$group


p<- ggplot(data=df,aes(x=Group,y=Distance_to_centroid,fill=groups))
p <-p + geom_boxplot()
p <-p + theme(axis.text.x=element_text(angle = -90, hjust = 0,vjust=0.5)) + stat_compare_means() +theme_bw() +
  scale_fill_manual(values = c("#f7d0c6","#e76f51"))
p
dev.off()
## quartz_off_screen 
##                 2
p

pdf("Figures/Dispersion figure2.pdf",width=3,height=10)
data.add.bf <-  (varespec.bray.use$`1 year_Species`[[2]])
data.add.bf$bf <- ifelse(data.add.bf$exact_age*12<data.add.bf$bf_duration_imp,1,
                         ifelse(data.add.bf$subjectnumber%in%as.character(nobf.id),0,NA))

bd <- vegan::betadisper(varespec.bray.use$`1 year_Species`[[1]], data.add.bf$bf)
boxplot(bd)
df <- data.frame(Distance_to_centroid=bd$distances,Group=bd$group)
groups <- bd$group

p<- ggplot(data=df,aes(x=Group,y=Distance_to_centroid,fill=groups))
p <-p + geom_boxplot()
p <-p + theme(axis.text.x=element_text(angle = -90, hjust = 0,vjust=0.5)) + stat_compare_means() +theme_bw()+
  scale_fill_manual(values = c("#f7d0c6","#e76f51"))
p
dev.off()
## quartz_off_screen 
##                 2
p

Generate bootstrap PERMANOVA results (Figure 3B)

# rm(list=ls())
# library(phyloseq)
# library(psych)
# library(corrplot)
# library("psych")
# library(ggplot2)
# library(car)
# library(magrittr)
# library(ggcorrplot)
# library(missForest)
# library(xlsx)
# library(WGCNA)
# library(ggpubr)
# library(lavaan)
# library(limma)
# library(metaMint)
# library(lubridate)
# source("/Users/darlene.dai/Desktop/Darlene Dai/Common function/UVA&MVA function.R")
# source("/Users/darlene.dai/Desktop/Darlene Dai/Common function/Demographic Function.R")
# 
# work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"
# setwd(work.dir)
# load("Results/P1 Processed Metagenomic data.RData")
# load("Results/P2 Univariate Analysis of SES.Rdata")
# 
# UVA.res.all <- subset(UVA.res.outcome, !Variables%in%c("sitetoronto","sitevancouver","sitewinnipeg","Season2.Summer","Season3.Fall","Season4.Winter"))
# cov.vars <- c("MR1_latent.raw","male",
#               "atbx.microbiome.new", "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
#               "awayhome1h_3m", "bf","bw_sd", "canue_Zdweldensity_pre18w" ,
#               "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
#               "dog_1y", "fasthma","father_atopy_1y",
#               "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
#               "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
#               "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
#               "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
#               "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter")
# 
# data.withmissing.bf <- merge(data.withmissing,subset(data.div, Visit=="3 month"),by.x="subjectnumber", by.y="SubjectNumber")
# data.withmissing.bf$bf <- ifelse(data.withmissing.bf$exact_age*12<data.withmissing.bf$bf_duration_imp,1, 0)
# nobf.id <- unique(data.withmissing.bf$subjectnumber[data.withmissing.bf$bf==0 & !is.na(data.withmissing.bf$bf) &  data.withmissing.bf$bf_duration_imp<3])
# nobf.id2 <- unique(data.withmissing.bf$subjectnumber[data.withmissing.bf$bf==0 & !is.na(data.withmissing.bf$bf)])
# 
# ############################################################################################################
# library(vegan)
# technical.vars <- c("ProcessingPeriod" ,"exact_age")
# 
# PERMANOVA.UVA <- NULL
# visit.all <- c("1 year","3 month")
# vars.use <- cov.vars
# 
# cohorts <- c( "subBF","NoBF")
# bootstrap.is <- 100
# set.seed(2423987)
# seed.used <- sample(10000:1000000, bootstrap.is)
# 
# for(bootstrap.i in 1:bootstrap.is){
#   for(cohort in cohorts){
#     for(data.type in c("Species")){
#       if(data.type=="Species"){
#         OTU.use <- RBNME_species_MCLR
#       }
#       if(data.type=="META"){
#         OTU.use <- RBMETA
# 
#       }
#       for(visit in visit.all){
#         if(visit%in%c("3 month", "1 year")){
#           s.use <- as.character(data.div$SampleID[data.div$Visit==visit])
#           s.use.subjectid <- as.character(data.div$SubjectNumber[data.div$Visit==visit])
#         }
#         for(missing in c("raw")){
#           if(missing=="raw"){data.cli.p <- data.withmissing[data.withmissing$subjectnumber%in%s.use.subjectid,]}
#           if(missing=="impute"){data.cli.p <- data.imputation[data.imputation$subjectnumber%in%s.use.subjectid,]}
#           data.cli.p <- merge(data.cli.p, data.div[s.use,c("SubjectNumber","SampleID","Visit","exact_age","ProcessingPeriod")],
#                               by.x="subjectnumber", by.y="SubjectNumber")
#           data.cli.p$atbx.microbiome.new <- ifelse(data.cli.p$Visit=="3 month", as.numeric(as.character(data.cli.p$atbx.micro3m)),
#                                                    as.numeric(as.character(data.cli.p$atbx.micro1y)))
#           data.cli.p$bf <- ifelse(data.cli.p$exact_age*12<data.cli.p$bf_duration_imp,1, 0)
# 
#           if(cohort=="subBF"){
#             data.cli.p <- subset(data.cli.p, bf==1)
#             vars.use <- vars.use[!vars.use%in%c("bf")]
#           }
#           if(cohort=="NoBF"){
#             data.cli.p <- subset(data.cli.p, subjectnumber%in%as.character(nobf.id))
#             vars.use <- vars.use[!vars.use%in%c("bf")]
#           }
#           if(visit%in%c("3 month", "1 year")){
#             rownames(data.cli.p) <- data.cli.p$subjectnumber
#           }
#           s.overlap <- data.cli.p$subjectnumber
#           s.overlap <- as.character(s.overlap)
#           otu.table.use <- data.frame(otu_table(OTU.use))
#           otu.table.sub <- otu.table.use[s.use,]
#           rownames(otu.table.sub) <- s.use.subjectid
# 
#           for(var.use in vars.use){
# 
#             var.model.use <- c("ProcessingPeriod" ,"exact_age", var.use)
#             full.model <- paste("otu.table.model ~ ", paste(var.model.use, collapse = "+"))
#             data.cli.p.nomissing <- na.omit(data.cli.p[,c(var.model.use,"site")])
# 
#             s.nomissing <- as.character(rownames(data.cli.p.nomissing))
#             set.seed(seed.used[bootstrap.i])
#             s.overlap.bootstrap <- (sample(s.nomissing,188,replace = T))
# 
#             data.cli.model <- data.cli.p[s.overlap.bootstrap,]
#             otu.table.model <- otu.table.sub[s.overlap.bootstrap,]
#             rownames(data.cli.model)
#             rownames(otu.table.model)
#             set.seed(343834)
#             margin.permanova <- adonis2(as.formula(full.model),
#                                         data = data.cli.model,
#                                         permutations = 999,
#                                         method="euclidean",
#                                         by="margin",
#                                         strata =data.cli.model$site)
# 
#             res.margin <- data.frame(Data=data.type,
#                                      Imputation=missing,
#                                      Visit=visit,
#                                      Cohort=cohort,
#                                      Var=c(var.model.use,"Residual","Total"),
#                                      N=length(s.nomissing),
#                                      Tes=var.use,
#                                      R2.margin=margin.permanova$R2,
#                                      Fvalue.margin=margin.permanova$F,
#                                      p.margin=margin.permanova$`Pr(>F)`,
#                                      bootstrap=bootstrap.i)
# 
#             res <- res.margin
#             PERMANOVA.UVA <- rbind(PERMANOVA.UVA, res)
#             save(PERMANOVA.UVA, file="Results/P3 UVA PERMANOVA subcohort Bootstrap188.RData")
#           }
#         }
#       }
#     }
#   }
# }

load("Results/P3 UVA PERMANOVA subcohort Bootstrap188.RData")
data.map.use <- data.map
PERMANOVA.all <- subset(PERMANOVA.UVA, Var%in%cov.vars[!cov.vars%in%"EBF_6m"])
PERMANOVA.all[PERMANOVA.all$Var%in%c("no2.y1","maternaldistress_perceived_1y","awayhome1h_1y") & PERMANOVA.all$Visit=="3 month","R2.margin"] <- 0
PERMANOVA.all[PERMANOVA.all$Var%in%c("no2.y1","maternaldistress_perceived_1y","awayhome1h_1y") & PERMANOVA.all$Visit=="3 month","p.margin"] <- NA
PERMANOVA.all[PERMANOVA.all$Var%in%c("no2.y1","maternaldistress_perceived_1y","awayhome1h_1y") & PERMANOVA.all$Visit=="3 month","Fvalue.margin"] <- NA


PERMANOVA.all.plot <- merge(PERMANOVA.all,data.map.use ,by.x="Var", by.y="Vars",all.x=T)
PERMANOVA.all.plot$Visit <- factor(PERMANOVA.all.plot$Visit, levels=c("3 month", "1 year"), ordered=T)
PERMANOVA.all.plot$U <- ifelse(PERMANOVA.all.plot$p.margin<0.05, "+","")
PERMANOVA.all.plot$Data <- factor(PERMANOVA.all.plot$Data, levels=c( "Species","META"), ordered=T)
PERMANOVA.all.plot <- subset(PERMANOVA.all.plot, bootstrap%in%c(1:100))
dd <- unique(subset(PERMANOVA.all.plot))
rank.dd <- ddply(dd, .(Label,Category,Visit,Cohort), summarise,
                 mean.log.p2=mean(-log10(p.margin )),
                 mean.r2=mean(R2.margin),
                 se=1.96 * sd(R2.margin) / sqrt(length(R2.margin)),
                 sig.freq=length(U[U=="+"])/length(U))
rank.dd <- rank.dd[order(rank.dd$mean.r2,decreasing = F),]
rank.dd$Label <- factor(rank.dd$Label, levels=unique(dd$Label), ordered=T)
rank.dd$Significance.prev <- ifelse(rank.dd$sig.freq>=0.8,1,0)
rank.dd$Significance.mean<-ifelse(rank.dd$mean.log.p2>log10(0.05)*-1, 1, 0)
rank.dd$mean.r2 <- rank.dd$mean.r2*100
rank.dd$se<- rank.dd$se * 100
rank.dd$mean.r2.neg<-ifelse(rank.dd$Cohort=="NoBF", rank.dd$mean.r2 * -1, rank.dd$mean.r2 )
rank.dd$se.neg<-ifelse(rank.dd$Cohort=="NoBF", rank.dd$se * -1, rank.dd$se)
rank.dd$Cohort<-factor(rank.dd$Cohort, levels = c("SubBF","NoBF"))
rank.dd$Category <- factor(rank.dd$Category, levels=c("SES","Pregnancy","Birth",
                                                                        "Postnatal",
                                                                        "Home Environment",
                                                                        "Neighbourhood Environment",
                                                                        "Parental Diet/Health"), ordered=T)
rank.dd$Label <- factor(rank.dd$Label, levels=rev(layer_scales(permanova.plot, 1, 1)$y$range$range),ordered=T)
plot.subbootstrap <- ggplot(subset(rank.dd,!is.na(Category) &Label!="SES Index"), aes(x=Label, y=mean.r2.neg, fill=Category, color=Category, alpha=Significance.prev)) +
  geom_bar(position=position_dodge(), stat="identity") +
  geom_errorbar(aes(ymin= mean.r2.neg - se.neg,
                     ymax= mean.r2.neg + se.neg),
                 width=.6,
                 position=position_dodge(.9))+
  facet_grid(Visit~Category,space="free", scales = "free_x")+
  scale_fill_manual(values = c("#E9C46A","#F4A261","#E76F51","#2A9D8F","#287271","#9A4770"))+
  scale_color_manual(values = c("#E9C46A","#F4A261","#E76F51","#2A9D8F","#287271","#9A4770"))+
    theme_bw() +
  geom_hline(yintercept = 0)+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
  ylab("Mean of Beta-diversity variance explained (R2) %")+
  coord_cartesian(ylim = c(-2.3, 2.3))
plot.subbootstrap

pdf("Figures/P3 bootstrap PERMANOVA R2_Dec12.pdf", height=10, width=16)
plot.subbootstrap
dev.off()
## quartz_off_screen 
##                 2

Run Maaslin2 analysis (Figure 4, 5)

Identify the species associated with SES

rm(list=ls())
library(phyloseq)
library(psych)
library(corrplot)
library("psych")
library(ggplot2)
library(car)
library(magrittr)
library(ggcorrplot)
library(missForest)
library(xlsx)
library(WGCNA)
library(ggpubr)
library(lavaan)
library(limma)
library(metaMint)
library(lubridate)
library(Maaslin2)
library(tidyverse)
library(phyloseq)
library(copiome)
library(ggpubr)
library(ggforce)
library(patchwork)
library(gtsummary)
library(Maaslin2)
library(scales)
library("ggsci")
library(dplyr)
library(cowplot)
library(plyr)
library(reshape2)
library(colorspace)
work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"
# work.dir <- "~/Documents/SES_Manuscript/"
setwd(work.dir)
#####################################################################
load("Results/P1 Processed Metagenomic data.RData")


# Maaslin2 analysis (no need to run again)
#Remove the samples not prevalent enough
remove_rare <- function( table , cutoff_pro ) {
  row2keep <- c()
  cutoff <- ceiling( cutoff_pro * ncol(table) )
  for ( i in 1:nrow(table) ) {
    row_nonzero <- length( which( table[ i , ]  > 0 ) )
    if ( row_nonzero > cutoff ) {
      row2keep <- c( row2keep , i)
    }
  }
  return( table [ row2keep , , drop=F ])
}
library(vegan)
SES.maaslin <- NULL
SES.maaslin <- unique(SES.maaslin)
SES.vars <- c("MR1_latent.raw")
outcome.vars <- c("atopy5y", "asthma5y_ep", "overweight", "Tscore_abnormal")
cov.vars <- c("atbx.microbiome.new", "bf","EBF_6m","male",
              "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
              "awayhome1h_3m","bw_sd", "canue_Zdweldensity_pre18w" ,
              "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
              "dog_1y", "fasthma","father_atopy_1y",
              "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
              "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
              "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
              "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
              "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter",
               "bfhistory_m","bfhistory_m_time",
                                  "bfhistory_f","bfhistory_f_time",
                "PBscore",
                                    "WSscore",
                                    "BAscore","eaPBscore",
                                    "eaWSscore" ,                   
                                    "eaBAscore",
                                    "pb_sumscore",
                                    "ws_sumscore",
                                    "ba_sumscore"  ,                
                                    "eapb_sumscore",
                                    "eaws_sumscore",
                                    "eaba_sumscore","B2")
used.vars <- c(SES.vars, outcome.vars, cov.vars)

data.withmissing.bf <- merge(data.withmissing,subset(data.div, Visit=="3 month"),by.x="subjectnumber", by.y="SubjectNumber")

data.withmissing.bf$bf <- ifelse(data.withmissing.bf$exact_age*12<data.withmissing.bf$bf_duration_imp,1, 0)
nobf.id <- unique(data.withmissing.bf$subjectnumber[data.withmissing.bf$bf==0 & !is.na(data.withmissing.bf$bf) &
                                                      data.withmissing.bf$bf_duration_imp<3])

prev.cts <- c(0.1)
adj.vars.basics <- list(c("ProcessingPeriod", "exact_age"))
SES.maaslin <- NULL

# for(data.type in c("DIV","Species","META")){
#   if(data.type%in%c("DIV")){
#     norm.methods <- c("raw")
#     if(data.type=="DIV"){
#       visit.all <- c("3 month", "1 year","longitudinal")#
#     }else{
#       visit.all <- c("1 year")
#     }
#   }else{
#     norm.methods <- "MCLR"
#     visit.all <- c("longitudinal")
#   }
#   for(norm.method in norm.methods){
# 
#     if(norm.method=="raw" & data.type=="DIV"){
#       RBNME.use <- DIV
#       norm.use <- "none"
#       trans.use <- "none"
#     }
# 
#     if(norm.method=="MCLR"){
#       if(data.type=="Species"){
#         RBNME.use <- RBNME_species_MCLR
#       }
#       if(data.type=="KEGGNAMED"){
#         RBNME.use <- RBKEGGNAMED_MCLR
#       }
#       if(data.type=="META"){
#         RBNME.use <- RBMETA_MCLR
#       }
# 
#       norm.use <- "none"
#       trans.use <- "none"
#     }
#     if(norm.method=="CLR"){
#       if(data.type=="Species"){
#         RBNME.use <- RBNME_species_CLR
#       }
#       if(data.type=="KEGGNAMED"){
#         RBNME.use <- RBKEGGNAMED_CLR
#       }
#       if(data.type=="META"){
#         RBNME.use <- RBMETA_CLR
#       }
#       norm.use <- "none"
#       trans.use <- "none"
#     }
#     if(norm.method=="TSSLOG"){
#       if(data.type=="Species"){
#         RBNME.use <- RBNME_species
#       }
#       if(data.type=="KEGGNAMED"){
#         RBNME.use <- RBKEGGNAMED
#       }
#       if(data.type=="META"){
#         RBNME.use <- RBMETA
#       }
#       norm.use <- "none"
#       trans.use <- "LOG"
#     }
#     for(adj.vars.basic in adj.vars.basics){
#       for(visit in visit.all){
#         OTU.use <- RBNME.use
#         for(prev.ct in prev.cts){
#           min.use <- -Inf
#           prev.use <- -Inf
#           if(prev.ct==-Inf){
#             used.sp <- colnames(otu_table(RBNME.use))
# 
#           }else{
#             if(visit!="longitudinal"){
#               if(data.type=="Species"){
#                 RBNME.use.pvt <- RBNME_species
#               }
#               if(data.type=="KEGGNAMED"){
#                 RBNME.use.pvt <- RBKEGGNAMED
#               }
#               if(data.type=="META"){
#                 RBNME.use.pvt <- RBMETA
#               }
#               if(data.type=="DIV"){
#                 RBNME.use.pvt <- DIV
#               }
# 
#               otu.use.sgv <- subset_samples(RBNME.use.pvt, Visit==visit)
#               otu.use.sgv <- remove_rare(table=t(otu_table(otu.use.sgv)), cutoff_pro=0)
#               used.sp<-rownames(otu.use.sgv)
#             }
#             if(visit=="longitudinal"){
#               if(data.type=="Species"){
#                 RBNME.use.pvt <- RBNME_species
#               }
#               if(data.type=="KEGGNAMED"){
#                 RBNME.use.pvt <- RBKEGGNAMED
#               }
#               if(data.type=="META"){
#                 RBNME.use.pvt <- RBMETA
#               }
#               if(data.type=="DIV"){
#                 RBNME.use.pvt <- DIV
#               }
#               otu.use.sgv <- RBNME.use.pvt
#               otu.use.sgv <- remove_rare(table=t(otu_table(otu.use.sgv)), cutoff_pro=0)
#               #remove metaphlan.table.SGB.s.3m with prevalence less than 10%
#               used.sp<-rownames(otu.use.sgv)
#             }
#           }
# 
#           if(visit=="longitudinal"){
#             s.use.subjectid <-  names(which(table(data.div$SubjectNumber)>0))
#             s.use <- as.character(data.div$SampleID[data.div$SubjectNumber%in%s.use.subjectid])
#           }
#           if(visit%in%c("3 month", "1 year")){
#             s.use <- as.character(data.div$SampleID[data.div$Visit==visit])
#             s.use.subjectid <- as.character(data.div$SubjectNumber[data.div$Visit==visit])
#           }
#           for(missing in c("raw")){
#             if(missing=="raw"){data.cli.p <- data.withmissing[data.withmissing$subjectnumber%in%s.use.subjectid,]}
#             data.cli.p <- merge(data.cli.p,
#                                 data.div[s.use,c("SubjectNumber","Visit","SampleID","exact_age","ProcessingPeriod")],
#                                 by.x="subjectnumber", by.y="SubjectNumber")
# 
#             data.cli.p <- subset(data.cli.p, exact_age<1.5)
#             data.cli.p$atbx.microbiome <- ifelse(data.cli.p$atbx.1y.time<data.cli.p$exact_age*365,1,0)
#             data.cli.p$atbx.microbiome.new <- ifelse(data.cli.p$Visit=="3 month", as.numeric(as.character(data.cli.p$atbx.micro3m)),as.numeric(as.character(data.cli.p$atbx.micro1y)))
# 
#             data.cli.p$bf <- ifelse(data.cli.p$exact_age*12<data.cli.p$bf_duration_imp,1, 0)
# 
#             if(visit%in%c("3 month", "1 year")){
#               rownames(data.cli.p) <- data.cli.p$subjectnumber
#             }
#             if(visit=="longitudinal"){
#               rownames(data.cli.p) <- data.cli.p$SampleID
#             }
#             for(bf.sub in c("NoBF","AnyBF","All")){#,
# 
#               if(bf.sub=="All"){s.overlap <- rownames(data.cli.p)}
#               if(bf.sub=="AnyBF"){
#                 s.overlap <- rownames(data.cli.p)[data.cli.p$bf==1 & !is.na(data.cli.p$bf)]
#               }
#               if(bf.sub=="NoBF"){
#                 s.overlap <- rownames(data.cli.p)[data.cli.p$subjectnumber%in%nobf.id]
#               }
# 
#               s.overlap <- as.character(s.overlap)
#               data.cli.p.use <- data.cli.p[s.overlap,]
#               otu.table.use <- as.matrix(otu_table(OTU.use))
#               otu.table.sub <- otu.table.use[as.character(s.use),]
# 
#               if(visit%in%c("3 month", "1 year")){
#                 rownames(otu.table.sub) <- s.use.subjectid
#               }
#               if(visit=="longitudinal"){
#                 rownames(otu.table.sub) <- s.use
#               }
#               otu.table.sub <- otu.table.sub[s.overlap,]
# 
#               for(adj.race in c("none")){#"genetic",
#                 if(adj.race=="none"){
#                   adj.vars <- adj.vars.basic
#                   used.vars.use <- used.vars[!used.vars%in%c(paste0("ethnicity_pc",1:3))]
#                 }
#                 if(bf.sub%in%c("AnyBF","NoBF")){
#                   used.vars.bf <- used.vars.use[!used.vars.use%in%c("bf" ,"EBF_6m")]
#                 }else{
#                   used.vars.bf <- used.vars.use
#                 }
# 
#                 adj.vars.model <- adj.vars
#                 used.vars.model <- used.vars.bf
# 
#                 for(check.var in  c(  "B2")){#c(used.vars.model)
#                   all.vars <- unique(c(check.var, adj.vars.model))
#                   data.cli.p.nomissing <- na.omit(data.cli.p.use[,all.vars])
# 
#                   s.nomissing <- as.character(rownames(data.cli.p.nomissing))
# 
#                   data.cli.model <- data.cli.p.use[s.nomissing,]
#                   otu.table.model <- otu.table.sub[s.nomissing,]
#                   data.cli.model[,check.var] <- scale(as.numeric(as.character(data.cli.model[,check.var])))
#                   data.cli.model.use <- data.cli.model
#                   need.change.sp <- used.sp[!used.sp%in%colnames(otu.table.model)]
#                   used.sp[used.sp%in%need.change.sp] <- paste0("X",used.sp[used.sp%in%need.change.sp])
#                   otu.table.model.use <- otu.table.model[rownames(data.cli.model.use),used.sp]
#                   otu.table.model.use <- na.omit(otu.table.model.use)
#                   data.cli.model.use <- data.cli.model.use[rownames(otu.table.model.use),]
#                   if(visit%in%c("3 month", "1 year")){
#                     masslin.res  <- Maaslin2(
#                       input_data = otu.table.model.use,
#                       input_metadata = data.cli.model.use,
#                       output = "Metagenomic",
#                       normalization = norm.use,
#                       transform = trans.use,
#                       min_abundance = min.use,
#                       min_prevalence = prev.use,
#                       plot_heatmap = FALSE,
#                       plot_scatter = FALSE,
#                       fixed_effects = c(all.vars),
#                       random_effects = "site")
# 
#                     res <- masslin.res$results
#                     res <- subset(res)
#                     res$N <- nrow(otu.table.model)
#                     res$Model <- "SingleVisit"
#                   }
# 
#                   if(visit%in%c("longitudinal")){
# 
#                     data.cli.model.use[,check.var] <- as.numeric(as.character(data.cli.model.use[,check.var]))
#                     data.cli.model.use$time_interaction <- data.cli.model.use$exact_age*data.cli.model.use[,check.var]
# 
#                     masslin.res.long  <- Maaslin2(
#                       input_data = otu.table.model.use,
#                       input_metadata = data.cli.model.use,
#                       output = "Metagenomic",
#                       normalization = norm.use,
#                       transform = trans.use,
#                       min_abundance = min.use,
#                       min_prevalence = prev.use,
#                       plot_heatmap = FALSE,
#                       plot_scatter = FALSE,
#                       fixed_effects = all.vars,
#                       random_effects = c("subjectnumber","site"))
#                     masslin.res.long.int  <- Maaslin2(
#                       input_data = otu.table.model.use,
#                       input_metadata = data.cli.model.use,
#                       output = "Metagenomic",
#                       normalization = norm.use,
#                       transform = trans.use,
#                       min_abundance = min.use,
#                       min_prevalence = prev.use,
#                       plot_heatmap = FALSE,
#                       plot_scatter = FALSE,
#                       fixed_effects = c(all.vars,"time_interaction"),
#                       random_effects = c("subjectnumber","site"))
# 
#                     res1 <- masslin.res.long$results
#                     res2 <- masslin.res.long.int$results
#                     res1$Model <- "Nointeract"
#                     res2$Model <- "Interact"
# 
#                     res <- rbind(res1, res2)
#                     res$N <- nrow(otu.table.model)
#                   }
# 
#                   res.all <- res
#                   res.all$check.var <- check.var
#                   res.all$Data <- data.type
#                   res.all$Visit <- visit
#                   res.all$Race.Adj <- adj.race
#                   res.all$BFsub <- bf.sub
#                   res.all$adjbasic <- paste(adj.vars.basic, collapse = " + ")
#                   res.all$Normalization <- norm.method
#                   res.all$Prevalence_cutoff <- prev.ct
#                   SES.maaslin <- rbind(SES.maaslin, res.all)
#                   save(SES.maaslin, file="Results/P5 Maaslin2 Results.RData")
# 
#                 }
#               }
#             }
#           }
#         }
#       }
#     }
#   }
# }
load("Results/P5 Maaslin2 Results.RData")

Summarize the results from MAaslin2 analysis

SES.maaslin.combine <- unique(SES.maaslin)
######################################################################
#Combine the models with and without interaction. If slope not significant (p-value > 0.05), use the models without interaction.  
qval.ct <- 0.1
exclude.val <- c("toronto","vancouver","winnipeg","square_age","exact_age","ProcessingPeriod","1")
check.var.use <- unique(SES.maaslin.combine$check.var)

SES.masslin.all <- NULL
adj.vars.basics <- list(c("ProcessingPeriod", "exact_age","site"))
for(BFsub.use in c("All","AnyBF","NoBF")){
  for(adj.vars.basic.use in unique(SES.maaslin.combine$adjbasic)){
    for(norm.use in c("MCLR")){
      SES.masslin.new <- subset(SES.maaslin.combine,   BFsub==BFsub.use & Race.Adj=="none" & 
                                  Normalization==norm.use & adjbasic==adj.vars.basic.use &
                                  Visit=="longitudinal" & Data=="Species" & Prevalence_cutoff==0.1)
      for(check.var.i in check.var.use){
        ses.sp.int <- subset(SES.masslin.new, check.var%in%check.var.i & value%in%c("time_interaction") & !value%in%exclude.val & Model=="Interact" )
        ses.sp.main <-  subset(SES.masslin.new, check.var%in%check.var.i & !value%in%exclude.val & Model=="Nointeract" )
        ff.no.int <- subset(ses.sp.int, pval>=0.05)
        ff.sig.int <-  subset(ses.sp.int, pval<0.05)
        
        ses.sp.int.all <-  subset(SES.masslin.new, check.var%in%check.var.i & value%in%c("time_interaction",check.var.i,"exact_age") &
                                    Model=="Interact" )
        ses.sp.main.all <- subset(SES.masslin.new, check.var%in%check.var.i & value%in%c(check.var.i,"exact_age")  & Model=="Nointeract")
        ses.new.i <- rbind(ses.sp.int.all,
                           ses.sp.main.all)
        SES.masslin.all <- rbind(SES.masslin.all, ses.new.i)
      }
    }
  }
}
SES.masslin.all$feature_update <- strsplit2(SES.masslin.all$feature,"__")[,1]
dup.name <- strsplit2(unique(SES.masslin.all$feature),"__")[,1][duplicated(strsplit2(unique(SES.masslin.all$feature),"__")[,1])]
SES.masslin.all$feature_update[SES.masslin.all$feature_update %in%dup.name] <- SES.masslin.all$feature[SES.masslin.all$feature_update %in%dup.name] 
SES.masslin.all$feature_update <- gsub("  "," ",gsub("_"," ",SES.masslin.all$feature_update))
SES.masslin.all <- unique(SES.masslin.all)

SES.masslin.all.use <- subset(SES.masslin.all, Normalization=="MCLR" & BFsub=="All" &
                                adjbasic=="ProcessingPeriod + exact_age" )

######################################################################

######################################################################
#Longitudinal analysis results for SES
check.var.use <- c("MR1_latent.raw")
#Species associated with SES
ses.sp.int <- subset(SES.masslin.all.use,
                     qval<qval.ct & check.var%in%check.var.use & value%in%c("time_interaction"))
ses.sp.main <- subset(SES.masslin.all.use, Model%in%"Nointeract"&
                      qval<qval.ct & check.var%in%check.var.use & value%in%c(check.var.use) & !value%in%exclude.val)
ses.sig.f <- unique(c(ses.sp.int$feature))
ses.sp.main <- unique(ses.sp.main$feature)[!unique(ses.sp.main$feature)%in%ses.sig.f]
ses.sp.long <- subset(SES.masslin.all.use, check.var%in%check.var.use & feature%in%unique(c(ses.sig.f,ses.sp.main)))

#Create the pattern of change
ses.sp.long.pattern <- ses.sp.long
ses.sp.long.pattern$coef[ses.sp.long.pattern$qval>0.1 &ses.sp.long.pattern$value!="exact_age" ] <- 0
sp.increase <- subset(SES.masslin.all.use, value=="exact_age" & coef>0 & check.var%in%check.var.use & Model=="Interact")$feature
sp.decrease <- subset(SES.masslin.all.use, value=="exact_age" & coef<0 & check.var%in%check.var.use & Model=="Interact")$feature

pattern.type <- dcast(ses.sp.long.pattern[,c("feature","value","coef","Model")], Model+ feature ~ value, value.var = c("coef"))
pattern.type <- pattern.type[order(pattern.type$Model),]

pattern.type$time_trend <- ifelse(pattern.type$exact_age>0,"Increase",
                                  ifelse(pattern.type$exact_age<0,"Decrease","No change"))
pattern.type$slope_SES <- ifelse(is.na(pattern.type$time_interaction),"No change",
                                 ifelse(pattern.type$time_interaction>0,"High",
                                        ifelse(pattern.type$time_interaction<0,"Low","No change")))
pattern.type$baseline_SES <- ifelse(pattern.type$MR1_latent.raw>0,"High",
                                    ifelse(pattern.type$MR1_latent.raw<0,"Low","No change"))
pattern.type.1 <- subset(pattern.type,slope_SES=="No change" & feature%in%ses.sp.main & Model=="Nointeract")
pattern.type.2 <- subset(pattern.type,slope_SES!="No change" & feature%in%ses.sig.f & Model=="Interact")
pattern.type <- rbind(pattern.type.1,pattern.type.2)
pattern.type$pattern <- ifelse(pattern.type$slope_SES=="No change", paste(pattern.type$time_trend, pattern.type$baseline_SES),
                                paste(pattern.type$time_trend, pattern.type$baseline_SES, pattern.type$slope_SES, sep="_"))
 
table(pattern.type$pattern)


ses.sp.long <- merge(ses.sp.long, pattern.type[,c("feature","pattern")], by="feature",all.x=T)
ses.sp.long$sig <- ifelse(ses.sp.long$qval<0.1,"sig","nosig")
ses.sp.long$Effect <- ifelse(ses.sp.long$value=="MR1_latent.raw"& ses.sp.long$Model=="Interact", "Baseline", 
                             ifelse(ses.sp.long$value=="MR1_latent.raw"& ses.sp.long$Model=="Nointeract", "Overall", 
                                    ifelse(ses.sp.long$value=="time_interaction", "Slope","Time")))
table(ses.sp.long$pattern)
ses.sp.long$pattern <- factor(ses.sp.long$pattern, levels=c("Increase High" ,
                                                            "Increase Low" ,
                                                            
                                                            "Increase_No change_High",
                                                            "Increase_No change_Low",
                                                            
                                                            "Increase_Low_High"  ,
                                                            "Increase_High_Low" ,
                                                            
                                                             "Decrease_Low_High" ,
                                                             "Decrease_High_Low"),
                              ordered=T)

ses.sp.long$Direction <- ifelse(ses.sp.long$coef>0,"Positive","Negative")
sp.order.ses <- ses.sp.long[ses.sp.long$value=="MR1_latent.raw",]
sp.order.ses <- sp.order.ses[order(abs(sp.order.ses$coef)),]
sp.order.ses <- sp.order.ses[order(sp.order.ses$Model,decreasing=F),]
ses.sp.long$feature_update <- factor(ses.sp.long$feature_update,levels=unique(sp.order.ses$feature_update), ordered=T)
ses.sp.long$Effect <- factor(ses.sp.long$Effect, levels=c("Baseline","Slope","Overall","Time"), ordered=T)
ses.sp.long$Model <- ifelse(ses.sp.long$Model=="Interact","Model with interaction", "Model without interaction")

ses.plot <- ggplot(subset(ses.sp.long ,Effect !="Time" ), 
                   aes(x=coef, y=feature_update,fill=Direction,alpha=sig)) + 
  theme_bw() + 
  xlab("Coefficient") +
  geom_errorbar(aes(xmin=coef-1.96*stderr,xmax=coef+1.96*stderr), width=.2, position=position_dodge(0.5)) +
  geom_point(position=position_dodge(0.5), size = 3, pch = 21) +
  facet_grid(pattern~Model+Effect,scale="free_y",space="free_y") +
  ylab("") + ggtitle("") +
  xlab("") + xlab("MaAsLin2 coefficient") + ylab("") +
  scale_shape_manual(values=seq(0,10)) +
  scale_fill_manual(values = c( 
    "black","black"  ))+ 
  scale_alpha_discrete(range = c(0.5,1))+
  geom_vline(xintercept=0)
pdf("Figures/P5 Maaslin2 Species SES.pdf", height=8, width=10)
plot(ses.plot)
dev.off()

sig.sp.ses <- unique(ses.sp.long$feature)
save(sig.sp.ses, file="Results/P5 Maaslin2 sig ses species mclr.RData")

Generate figure of species assocaited with SES (Figure S3A)

plot(ses.plot)

Species assocaited with early-life factors

ff.order <- c(layer_scales(ses.plot, 1, 2)$y$range$range,
              layer_scales(ses.plot, 2, 2)$y$range$range,
              layer_scales(ses.plot, 3, 2)$y$range$range,
              layer_scales(ses.plot, 4, 2)$y$range$range,
              layer_scales(ses.plot, 5, 2)$y$range$range,
              layer_scales(ses.plot, 6, 2)$y$range$range,
              layer_scales(ses.plot, 7, 2)$y$range$range,
              layer_scales(ses.plot, 8, 2)$y$range$range)

######################################################################
#Longitudinal analysis results for SES & early life factors
################################################################################
check.var.use <- unique(SES.maaslin.combine$check.var)

used.vars <- c("MR1_latent.raw","atbx.microbiome.new", "bf","EBF_6m",
               "atbx.m.birth", "atbx.m.preg", "awayhome1h_1y" ,
               "awayhome1h_3m","bw_sd", "canue_Zdweldensity_pre18w" ,
               "cat_1y", "condition_GestationalDiabetes_mother_prelabour",
               "dog_1y", "fasthma","father_atopy_1y",
               "freq_score_basic", "gest_days", "hometype_3m","masthma","maternaldistress_perceived_1y",
               "maternaldistress_perceived_pre18w", "mom_bmi_best", "mom_UPFContr", "mother_atopy_1y",
               "no2.preg", "no2.y1", "num_siblings", "postnatal_smoke",
               "Pregnancy.Tdens250", "prenatal_smoke", "rural", "furniture_densityclutter_3m",
               "home_plant_3m", "floor_carpet_3m", "mould_3m_mh", "vaginal", "fall","summer", "winter")

ses.sig.f.all <- unique(c(ses.sp.main,ses.sig.f))
all.sp <- subset(SES.masslin.all.use, !value%in%exclude.val & feature%in%ses.sig.f.all & check.var%in%used.vars)
all.sp$U <- ifelse(all.sp$qval<0.1,"*","")


all.sp$Effect <- ifelse(all.sp$value=="time_interaction","Slope",
                        ifelse(all.sp$Model=="Interact", "Baseline",
                                ifelse(all.sp$Model=="Nointeract", "Overall",NA)))
all.sp <- merge(all.sp, pattern.type[,c("feature","pattern")], by="feature")
all.sp$pattern <- factor(all.sp$pattern, levels=c("Increase High" ,
                                                            "Increase Low" ,
                                                            
                                                            "Increase_No change_High",
                                                            "Increase_No change_Low",
                                                            
                                                            "Increase_Low_High"  ,
                                                            "Increase_High_Low" ,  
                                                             "Decrease_Low_High" ,
                                                             "Decrease_High_Low"), ordered=T)

all.sp <- merge(all.sp, data.map, by.x="check.var", by.y="Vars",all.x=T)
all.sp.use <- subset(all.sp, Category!="Health")
all.sp.use$Category <- factor(all.sp.use$Category, levels=c("SES","Pregnancy",
                                                            "Birth",
                                                            "Postnatal",
                                                            "Home Environment",
                                                            "Neighbourhood Environment",
                                                            "Parental Diet/Health"),
                              ordered=T)
all.sp.use$Effect <- factor(all.sp.use$Effect, levels=c("Baseline", "Slope","Overall"), ordered=T)
all.sp.use$feature_update <- factor(all.sp.use$feature_update,
                                    levels=c(ff.order), ordered=T)
all.sp.update <- NULL
for(check.var.i in unique(all.sp.use$check.var)){
  ff.main <- subset(all.sp.use, check.var == check.var.i & Model=="Nointeract" & Effect=="Overall")
  ff.int <- subset(all.sp.use, check.var == check.var.i & Model=="Interact" & Effect=="Slope")
  ff.all <- rbind(ff.main,ff.int)
  all.sp.update <- rbind(all.sp.update, ff.all)
}
  

all.sp.use.sig <- unique(subset(all.sp.update, qval<0.1, select=c("check.var","feature_update","Label","Category","pattern")))
all.sp.use.sig$feature_update <- factor(all.sp.use.sig$feature_update,
                                        levels=c(ff.order), ordered=T)
sig.all.barplot <- ddply(all.sp.use.sig, .(Label,Category), summarise, N=length(feature_update))
sig.all.barplot2 <- ddply(subset(all.sp.use.sig, Label!="SES"),.(feature_update,pattern,Category), 
                          summarise, N=length(feature_update))
sig.all.barplot2.sum <- ddply(sig.all.barplot2, .(feature_update,pattern), 
                              summarise, All=length(feature_update))
sig.all.barplot2 <- merge(sig.all.barplot2,sig.all.barplot2.sum,by=c("feature_update","pattern"),all = T )
sig.all.barplot2$Percent <- sig.all.barplot2$N/sig.all.barplot2$All

df2 <- subset(all.sp.use.sig, Label!="SES Index") %>%
  group_by(feature_update, pattern,Category) %>%
  dplyr::summarise(n=n())%>%
  mutate(percent = (n / sum(n)), cumsum = cumsum(percent),N=n)
df2$Category <- factor(df2$Category, levels=c("Pregnancy",
                                              "Birth",
                                              "Postnatal",
                                              "Home Environment",
                                              "Neighbourhood Environment",
                                              "Parental Diet/Health"),
                       ordered=T)
sig.all.barplot <- sig.all.barplot[order(sig.all.barplot$N,decreasing=T),]
sig.all.barplot$Label <- factor(sig.all.barplot$Label, levels=unique(sig.all.barplot$Label), ordered = T)
all.sp.use.sig$Label <- factor(all.sp.use.sig$Label, levels=unique(sig.all.barplot$Label), ordered = T)
df3 <- ddply(df2,.(feature_update),summarise, N=sum(n))
df3 <- df3[order(df3$N),]
df2$feature_update <- factor(df2$feature_update, levels=unique(df3$feature_update), ordered=T)
all.sp.use.sig$feature_update <- factor(all.sp.use.sig$feature_update, levels=unique(df3$feature_update), ordered=T)
gg1 <- ggplot(data=df2, aes(x=n, y=feature_update,fill = Category)) +
  geom_bar(stat="identity") + 
  scale_fill_manual(values=c( "#E9C46A","#F4A261", "#E76F51", "#2A9D8F", "#287271", "#9A4770"))+
  facet_grid(pattern~.,scales = "free",space = "free") +
  theme_void() +
  theme(legend.position = "none", strip.background = element_blank(),
        strip.text.x = element_blank())


gg2 <- ggplot(data=sig.all.barplot, aes(x=Label, y=N,fill=Category)) +
  geom_bar(stat="identity")+
  geom_text(aes(label=N), vjust=1.6, color="white", size=3.5)+
  scale_fill_manual(values=c( "#8AB17D", "#E9C46A","#F4A261", "#E76F51", "#2A9D8F", "#287271", "#9A4770"))+
  facet_grid(~Category,scales = "free",space = "free") +
  theme_void() +
  theme(legend.position = "none", strip.background = element_blank(),
        strip.text.x = element_blank())

gg3 <- ggplot(subset(all.sp.use.sig), 
              aes(y=feature_update, x=Label, fill=Category)) +
  geom_point(pch=21,size=2) +
  theme_bw() + ylab("") + xlab("")+ theme(legend.position="bottom")+
  facet_grid(pattern~Category,scales = "free",space = "free") +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
        strip.text.x = element_blank()) + 
  scale_fill_manual(values=c( "#8AB17D", "#E9C46A","#F4A261", "#E76F51", "#2A9D8F", "#287271", "#9A4770"))

sig.sp.bf <- as.character(unique(subset(all.sp.use.sig, check.var%in%c("bf","EBF_6m"))$feature_update))
save(sig.sp.ses, sig.sp.bf,file="Results/P5 Maaslin2 sig ses species mclr.RData")

Generate figures of species assocaited SES and early-life factors (Figure 4A)

plot(gg1)

plot(gg2)

plot(gg3)

pdf("Figures/P5 Maaslin2 Species all exposomes simple.pdf", height=9, width=10)
plot(gg1)
plot(gg2)
plot(gg3)
dev.off()
## quartz_off_screen 
##                 2

Generate bubble figure to compare the effect of BF and SES (Figure 4B)

######################################################################
#Longitudinal analysis results for SES & BF narrow down to focus - Bubble plot
################################################################################
bf.sig.use.main <- unique(c(subset(SES.masslin.all.use, 
                            qval<qval.ct & Model=="Nointeract"&
                              value%in%c("MR1_latent.raw","bf") & 
                              !value%in%exclude.val )$feature))
bf.sig.use.slope <-  unique(subset(SES.masslin.all.use, 
                            qval<qval.ct & Model=="Interact"&
                              check.var%in%c("MR1_latent.raw","bf") & value=="time_interaction"&
                              !value%in%exclude.val )$feature)
all.sp.bf <- rbind(subset(SES.masslin.all.use, !value%in%exclude.val & feature%in%bf.sig.use.slope & check.var%in%c("MR1_latent.raw","bf") & value=="time_interaction" & Model=="Interact"),
                   subset(SES.masslin.all.use, !value%in%exclude.val & feature%in%bf.sig.use.main & check.var%in%c("MR1_latent.raw","bf") &  value%in%c("MR1_latent.raw","bf")& Model=="Nointeract"))


all.sp.bf$U <- ifelse(all.sp.bf$qval<0.1,"*","")
all.sp.bf$Effect <- ifelse(all.sp.bf$value=="time_interaction","Slope",
                        ifelse(all.sp.bf$Model=="Interact", "Baseline",
                                ifelse(all.sp.bf$Model=="Nointeract", "Overall",NA)))
 
all.sp.bf <- merge(all.sp.bf, data.map, by.x="check.var", by.y="Vars",all.x=T)
all.sp.bf$Effect <- factor(all.sp.bf$Effect, levels=c( "Slope","Overall"), ordered=T)
all.sp.bf$Label[all.sp.bf$Label=="SES Index"] <- "SES"
all.sp.bf$Label <- factor(all.sp.bf$Label, levels=c( "SES","Breastfeeding"), ordered=T)
all.sp.bf$Direction <- ifelse(all.sp.bf$coef>0,"Positive","Negative")
all.sp.bf$sig <- ifelse(all.sp.bf$qval<0.1,"sig","nosig")

#Dot plot
all.sp.bf.wide <- reshape2::dcast(all.sp.bf, feature +Effect ~ Label, value.var = "coef")
#To play add the mean relative
data.sp <- as.matrix(otu_table(RBNME_species_MCLR))
data.meta <- data.frame(sample_data(RBNME_species_MCLR))
data.sp.3m <- as.matrix(otu_table(subset_samples(RBNME_species_MCLR, Visit=="3 month")))
data.sp.1y <- as.matrix(otu_table(subset_samples(RBNME_species_MCLR, Visit=="1 year")))

rb.data <- merge(merge(data.frame(total_mean=apply(data.sp,2,mean)),
                       data.frame(m3_mean=apply(data.sp.3m,2,mean)), by="row.names"),
                 data.frame(y1_mean=apply(data.sp.1y,2,mean)),by.x="Row.names", by.y="row.names")

rb.data$Row.names <- gsub(" ","\\.",rb.data$Row.names)
all.sp.bf.wide <- merge(all.sp.bf.wide, rb.data, by.x="feature", by.y="Row.names",all.x=T)
data.sp.tax <- as.matrix(tax_table(RBNME_species_MCLR))
rownames(data.sp.tax) <-  gsub(" ","\\.",rownames(data.sp.tax))
all.sp.bf.wide <- merge(all.sp.bf.wide,data.sp.tax ,by.x="feature", by.y="row.names")
all.sp.bf.wide$Family <- gsub("f__","",all.sp.bf.wide$Family)
all.sp.bf.wide$Order <- gsub("o__","",all.sp.bf.wide$Order)
sesbf.p <- ggplot(data=all.sp.bf.wide, aes(x=SES, y=Breastfeeding))  + 
  geom_hline(yintercept = 0, color="grey")+
  geom_vline(xintercept = 0, color="grey")+
  geom_point(aes(size=total_mean,color=Order)) + #
  geom_smooth(method="lm", color="black")+ 
  scale_color_cosmic()+
  theme(aspect.ratio = 1)+
  facet_grid(~Effect,scale="free",space="free_y")+ 
  theme_bw()+
  stat_cor( geom = "label")

plot(sesbf.p)
## `geom_smooth()` using formula = 'y ~ x'

pdf("Figures/P5 Maaslin2 Bubble figure for SES and BF.pdf", height=4, width=9)
plot(sesbf.p)
## `geom_smooth()` using formula = 'y ~ x'
dev.off()
## quartz_off_screen 
##                 2

Generate heatmap of associaiton between early-life factors and microbiome (Figure S3B)

######################################################################
#Supplementary figure
all.sp.use$Label <- factor(all.sp.use$Label, levels=levels(all.sp.use.sig$Label), ordered=T)
gg <- ggplot(subset(all.sp.use), 
             aes(y=feature_update, x=Label)) +
  geom_tile(aes(fill=coef)) +
  geom_text(aes(label = U), color = "white", size = 4) +
  scale_fill_continuous_divergingx(palette = 'RdBu', mid = 0, l3 = 0, p1=0.5,p2=0.4,p3 = .1, p4 = .5,
                                   name="Coefficient",rev = T, na.value = "white") +
  theme_bw() + ylab("") + xlab("")+ theme(legend.position="bottom") +
  facet_grid(pattern~Category+Effect,scales = "free",space = "free") +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))

gg2 <- ggplot(subset(all.sp.use,Effect%in%c("Overall","Slope")), 
             aes(y=feature_update, x=Label)) +
  geom_tile(aes(fill=coef)) +
  geom_text(aes(label = U), color = "white", size = 4) +
  scale_fill_continuous_divergingx(palette = 'RdBu', mid = 0, l3 = 0, p1=0.5,p2=0.4,p3 = .1, p4 = .5,
                                   name="Coefficient",rev = T, na.value = "white") +
  theme_bw() + ylab("") + xlab("")+ theme(legend.position="bottom") +
  facet_grid(pattern~Category+Effect,scales = "free",space = "free") +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
plot(gg2)

pdf("Figures/P5 Maaslin2 Species all.pdf", height=9, width=15)
plot(gg2)
dev.off()
## quartz_off_screen 
##                 2

Species associated with phenotypes (Figure 5B)

phhe.sp <- subset(SES.masslin.all.use, qval<qval.ct & 
                               check.var%in%c("Tscore_abnormal",
                                              "asthma5y_ep","atopy5y", "overweight") & 
                               !value%in%exclude.val )


phhe.sp$Effect <- ifelse(phhe.sp$value=="time_interaction","Slope",
                        ifelse(phhe.sp$Model=="Interact", "Baseline",
                                ifelse(phhe.sp$Model=="Nointeract", "Overall",NA)))
phhe.sp.update <- NULL
for(check.var.i in unique(phhe.sp$check.var)){
  ff.main <- subset(phhe.sp, check.var == check.var.i & Model=="Nointeract" & Effect=="Overall")
  ff.int <- subset(phhe.sp, check.var == check.var.i & Model=="Interact" & Effect=="Slope")
  ff.all <- rbind(ff.main,ff.int)
  phhe.sp.update <- rbind(phhe.sp.update, ff.all)
}
  

phe.sig.use <- unique(phhe.sp.update$feature)
all.sp.phe <- subset(SES.masslin.all.use,  !value%in%exclude.val  &  
                       feature%in%phe.sig.use & 
                       check.var%in%c("MR1_latent.raw",
                                      "Tscore_abnormal",
                                      "asthma5y_ep","atopy5y", "overweight"))

all.sp.phe$U <- ifelse(all.sp.phe$qval<0.1,"*","")
all.sp.phe$Effect <- ifelse(all.sp.phe$value=="time_interaction","Slope",
                        ifelse(all.sp.phe$Model=="Interact", "Baseline",
                                ifelse(all.sp.phe$Model=="Nointeract", "Overall",NA)))


all.sp.phe <- merge(all.sp.phe, data.map, by.x="check.var", by.y="Vars",all.x=T)

all.sp.phe <- subset(all.sp.phe, Effect!="Baseline")

all.sp.phe$Effect <- factor(all.sp.phe$Effect, levels=c("Slope","Overall"), ordered=T)
all.sp.phe$Category <- factor(all.sp.phe$Category, levels=c("SES","Health"),
                              ordered=T)
all.sp.phe$Label[all.sp.phe$Label=="Overweight at 5y" ] <- "Overweight/obese"
all.sp.phe$Label[all.sp.phe$Label=="Abnormal child behavior at 5y" ] <-"Abnormal child behavior" 
all.sp.phe$Label[all.sp.phe$Label=="Atopy at 5y"] <-"Atopy" 
all.sp.phe$Label[all.sp.phe$Label=="Aasthma at 5y" ] <-"Asthma" 

all.sp.phe$Label <- factor(all.sp.phe$Label, levels=c( "SES Index","Overweight/obese", "Asthma","Atopy",
                                                       "Abnormal child behavior" ),
                           ordered=T)
all.sp.phe$SES <- ifelse(all.sp.phe$feature_update%in%ff.order, "Associated with SES", "Not associated with SES")

data.cc <- dcast(all.sp.phe, feature_update~Label+Effect,value.var = "coef")
data.cc[is.na(data.cc)] <- 0
rownames(data.cc) <- data.cc$feature_update
data.cc <- data.cc[,-1]
ord <- hclust( dist((data.cc), method = "euclidean"), method = "ward.D" )$order
sp.cc <- rownames(data.cc[ord,])


all.sp.phe.sig <- unique(subset(all.sp.phe, qval<0.1, select=c("check.var","feature_update","Label","Category","SES")))
save(sig.sp.ses, sig.sp.bf,all.sp.phe.sig,file="Results/P5 Maaslin2 sig ses species mclr.RData")


all.sp.phe.sig$feature_update <- factor(all.sp.phe.sig$feature_update,
                                        levels=c(sp.cc), ordered=T)
sig.all.barplot <- ddply(all.sp.phe.sig, .(Label,Category,SES), summarise,
                         N=length(feature_update))
sig.all.barplot2 <- ddply(subset(all.sp.phe.sig,check.var!="MR1_latent.raw"), 
                          .(feature_update,Category,SES), summarise, N=length(feature_update))
sig.all.barplot$SES <- factor(sig.all.barplot$SES, levels=c( "Not associated with SES" , "Associated with SES"  ),
                              ordered=T)
sig.all.barplot$Text <- NA
sig.all.barplot$Text[sig.all.barplot$Label!="SES" & sig.all.barplot$SES=="Associated with SES"] <- sig.all.barplot$N[sig.all.barplot$Label!="SES" & sig.all.barplot$SES=="Associated with SES"] 

sig.all.barplot2 <- sig.all.barplot2[order(sig.all.barplot2$SES,decreasing = T),]

sig.all.barplot2 <- sig.all.barplot2[order(sig.all.barplot2$N),]

sig.all.barplot2$feature_update <- factor(sig.all.barplot2$feature_update, levels=unique(sig.all.barplot2$feature_update), ordered=T)
all.sp.phe.sig$feature_update <- factor(all.sp.phe.sig$feature_update, levels=unique(sig.all.barplot2$feature_update), ordered=T)

library( "MetaNet")
all.sp.phe.sig$value <- 1
tab <- dcast(all.sp.phe.sig, feature_update~Label,value.var = "value")
tab[is.na(tab)] <- 0
rownames(tab) <- tab$feature_update
tab <- tab[,-1]
venn_net(tab) -> v_net
plot(v_net)

pdf("Figures/venn.pdf")
plot(v_net)
dev.off()
## quartz_off_screen 
##                 2

Plot B.infantis vs. SES and BF (Figure 5C,D)

###################################################################################################
check.var.use <- c("MR1_latent.raw","Tscore_abnormal","asthma5y_ep", "overweight","atopy5y")
names(check.var.use) <- c("SES",  "Abnormal child behavior","Asthma", "Overweight/obese","Atoppy")

phe.sp <- subset(SES.masslin.all,  Normalization=="MCLR" & 
                   adjbasic=="ProcessingPeriod + exact_age" & 
                   qval<qval.ct & check.var%in%check.var.use[check.var.use!="MR1_latent.raw"]  & 
                   !value%in%exclude.val & feature%in%unique(c(ses.sig.f,ses.sp.main)))
phe.sig.f <- unique(phe.sp$feature)

overweight.f <- unique(phe.sp$feature[phe.sp$check.var=="overweight"])
asthma.f <- unique(phe.sp$feature[phe.sp$check.var=="asthma5y_ep"])
tscore.f <- unique(phe.sp$feature[phe.sp$check.var=="Tscore_abnormal"])
atopy.f <- unique(phe.sp$feature[phe.sp$check.var=="atopy5y"])
data.sp <- data.frame(otu_table(RBNME_species_MCLR))
# data.sp[data.sp==0] <- min(data.sp[data.sp!=0])/2
# data.sp <- log(data.sp)
data.meta <- data.frame(sample_data(RBNME_species_MCLR))

data.sp.use <- merge(data.meta, data.sp[,phe.sig.f,drop=F], by.x="SampleID", by.y="row.names")
data.sp.use <- merge(data.withmissing, data.sp.use,by.x="subjectnumber", by.y="SubjectNumber")
data.sp.use <- subset(data.sp.use, exact_age<1.5)

data.sp.use$atbx.microbiome <- ifelse(data.sp.use$atbx.1y.time<data.sp.use$exact_age*365,1,0)
data.sp.use$atbx.microbiome.new <- ifelse(data.sp.use$Visit=="3 month", as.numeric(as.character(data.sp.use$atbx.micro3m)),
                                          as.numeric(as.character(data.sp.use$atbx.micro1y)))

data.sp.use$bf <- ifelse(data.sp.use$exact_age*12<data.sp.use$bf_duration_imp,1, 0)

data.sp.use.plot <- data.sp.use[,c("subjectnumber","SampleID", "exact_age","cat_SES","bfhistory_f","bfhistory_m","B2","bf",check.var.use, phe.sig.f)]

# ggplot(subset(data.sp.use.plot,exact_age<0.5 & bf==1), aes(log(B2),Bifidobacterium_longum.subsp.infantis)) + 
#   geom_point()

data.sp.use.plot.long <- melt(data.sp.use.plot, id.vars = c("subjectnumber","SampleID", "exact_age",check.var.use,"cat_SES",
                                                            "bfhistory_f","bfhistory_m","B2"))

data.sp.use.plot.long1 <- subset(data.sp.use.plot.long, select=c("subjectnumber","SampleID","exact_age","variable","value","cat_SES"))
names(data.sp.use.plot.long1) <- c("subjectnumber","SampleID","exact_age","variable","value","phenotype")

data.sp.use.plot.long2 <- subset(data.sp.use.plot.long,variable%in%asthma.f, select=c("subjectnumber","SampleID","exact_age","variable","value","asthma5y_ep"))
data.sp.use.plot.long2$asthma5y_ep <- ifelse(data.sp.use.plot.long2$asthma5y_ep==1,"Asthma","No asthma")
names(data.sp.use.plot.long2) <- c("subjectnumber","SampleID","exact_age","variable","value","phenotype")

data.sp.use.plot.long3 <- subset(data.sp.use.plot.long,variable%in%overweight.f ,  select=c("subjectnumber","SampleID","exact_age","variable","value","overweight"))
data.sp.use.plot.long3$overweight <- ifelse(data.sp.use.plot.long3$overweight==1,"Overweight/obese","Normal weight")
names(data.sp.use.plot.long3) <- c("subjectnumber","SampleID","exact_age","variable","value","phenotype")

data.sp.use.plot.long5 <- subset(data.sp.use.plot.long, variable%in%tscore.f , select=c("subjectnumber","SampleID","exact_age","variable","value","Tscore_abnormal"))
data.sp.use.plot.long5$Tscore_abnormal <- ifelse(data.sp.use.plot.long5$Tscore_abnormal==1,"Abnormal child behavior",
                                                 "Normal child behavior")
names(data.sp.use.plot.long5) <- c("subjectnumber","SampleID","exact_age","variable","value","phenotype")

data.sp.use.plot.long6 <- subset(data.sp.use.plot.long, variable%in%atopy.f , select=c("subjectnumber","SampleID","exact_age","variable","value","atopy5y"))
data.sp.use.plot.long6$atopy5y <- ifelse(data.sp.use.plot.long6$atopy5y==1,"Atopy",
                                         "No Atopy")
names(data.sp.use.plot.long6) <- c("subjectnumber","SampleID","exact_age","variable","value","phenotype")



data.sp.use.plot.long1$Category <- "SES"
data.sp.use.plot.long2$Category <- "Asthma"
data.sp.use.plot.long3$Category <- "Overweight/obese"
data.sp.use.plot.long5$Category <- "Abnormal Child Behavior"
data.sp.use.plot.long6$Category <- "Atopy"

data.sp.use.plot.long.all <- rbind(data.sp.use.plot.long1,data.sp.use.plot.long2,data.sp.use.plot.long3,data.sp.use.plot.long5,data.sp.use.plot.long6)
data.sp.use.plot.long.all$Category <- factor(data.sp.use.plot.long.all$Category, levels=c("SES","Overweight/obese","Asthma","Atopy","Abnormal Child Behavior"), ordered=T)

data.sp.use.plot.long.all <- merge(data.sp.use.plot.long.all, pattern.type[,c("feature","pattern")], by.x="variable", by.y="feature")
data.sp.use.plot.long.all$pattern <- factor(data.sp.use.plot.long.all$pattern, levels=c("Increase_High_No change","Increase_Low_No change",
                                                                                        "Increase_No change_High", "Increase_No change_Low",
                                                                                        "Increase_Low_High", "Increase_High_Low", 
                                                                                        "Decrease_High_Low", "Decrease_Low_High"), ordered=T)

unique(data.sp.use.plot.long.all$variable)
##  [1] Bacteroides_caccae.SGB1877              
##  [2] Bifidobacterium_dentium.SGB17234        
##  [3] Bifidobacterium_longum.subsp.infantis   
##  [4] Clostridium_innocuum.SGB4037            
##  [5] Clostridium_sp_C5_48.SGB4752            
##  [6] Eggerthella_lenta.SGB14809              
##  [7] Faecalibacterium_prausnitzii.SGB15316   
##  [8] Megasphaera_micronuciformis.SGB5868     
##  [9] Phocaeicola_dorei.SGB1815               
## [10] Ruminococcus_gnavus.SGB4584             
## [11] Ruminococcus_torques.SGB4608            
## [12] Ruthenibacterium_lactatiformans.SGB15271
## [13] Streptococcus_mitis.SGB8168             
## [14] Streptococcus_salivarius.SGB8005        
## [15] Streptococcus_salivarius.SGB8007_group  
## [16] Streptococcus_thermophilus.SGB8002      
## 17 Levels: bf ... Eggerthella_lenta.SGB14809
data.sp.use.plot.long.all <- merge(data.sp.use.plot.long.all, data.withmissing[,c("subjectnumber","bf_duration_imp")],by="subjectnumber",all.x=T)
data.sp.use.plot.long.all$BF <- ifelse(data.sp.use.plot.long.all$exact_age*12>data.sp.use.plot.long.all$bf_duration_imp,"Children without BF",
                                       "Children with BF")
data.sp.use.plot.long.all2 <- data.sp.use.plot.long.all
data.sp.use.plot.long.all2$BF <- "All children"
data.sp.use.plot.long.all <- rbind(data.sp.use.plot.long.all2, data.sp.use.plot.long.all)
Binf.p <- ggplot(subset(data.sp.use.plot.long.all, !is.na(phenotype) &variable%in%c("Bifidobacterium_longum.subsp.infantis")& Category=="SES" &
                          !is.na(BF)),
                 aes(exact_age, value, group=phenotype,fill=phenotype,col=phenotype)) +
  geom_smooth(method="lm") +
  facet_wrap(~BF,ncol=3) +
  theme_bw()+
  scale_fill_manual(values=c("#C3D7BD","#A4C19A","#5D836E","#3F615E")) +
  scale_color_manual(values=c("#C3D7BD","#A4C19A","#5D836E","#3F615E")) +
  xlab("Child age (yr)") +
  ylab("Relative abundance (mclr) of B. infantis")
plot(Binf.p)
## `geom_smooth()` using formula = 'y ~ x'

pdf("Figures/P5 phenotype sig sp.pdf", width=8, height=6)
plot(Binf.p)
## `geom_smooth()` using formula = 'y ~ x'
dev.off()
## quartz_off_screen 
##                 2
#Prevalence figure
data.binf.prev <- subset(data.sp.use.plot.long.all, !is.na(phenotype) &variable%in%c("Bifidobacterium_longum.subsp.infantis")& Category=="SES" & !is.na(BF))
data.binf.prev <- merge(data.binf.prev, data.div[,c("SampleID","Visit")],by=c("SampleID"),all.x=T)
data.binf.prev.s <- ddply(data.binf.prev, .(Visit,BF,phenotype,variable), summarise,
                          prev=length(which(value!=0))/length(value)*100)
data.binf.prev.s$Visit <- factor(data.binf.prev.s$Visit, levels=c("3 month", "1 year"), ordered=T)
Binf.prev <- ggplot(data.binf.prev.s,
                    aes(Visit, prev, group=phenotype,fill=phenotype,col=phenotype)) +
  geom_bar(stat="identity",position = "dodge") + 
  facet_wrap(~BF,ncol=3) +
  theme_bw()+
  scale_fill_manual(values=c("#C3D7BD","#A4C19A","#5D836E","#3F615E","#61C6E4")) +
  scale_color_manual(values=c("#C3D7BD","#A4C19A","#5D836E","#3F615E","#61C6E4")) +
  xlab("Visit") +
  ylab("Prevalence of B. infantis (%)")+
  geom_text(aes(label=paste0(round(prev,0),"%")), color="black", size=3.5,
            position=position_dodge(width=0.9), vjust=0.1)
plot(Binf.prev)

pdf("Figures/P5 phenotype sig sp prev.pdf", width=8, height=6)
plot(Binf.prev)
dev.off()
## quartz_off_screen 
##                 2
ss.binfantis <- unique(data.sp.use.plot.long.all$subjectnumber[data.sp.use.plot.long.all$value!=0 & data.sp.use.plot.long.all$variable=="Bifidobacterium_longum.subsp.infantis"])
ss.binfantis.no <- names(which(table(data.sp.use.plot.long.all$subjectnumber[data.sp.use.plot.long.all$value==0 & data.sp.use.plot.long.all$variable=="Bifidobacterium_longum.subsp.infantis"])==16))
save(ss.binfantis, file="Results/subjects with Binfantis.RData")

bf history vs. B.infantis (Figure S5, Figure 5F)

#Breastfeeding history vs. B. infantis prevalence
data.withmissing$Binfantis.pre <- ifelse(data.withmissing$subjectnumber%in%ss.binfantis, 1,
                                          ifelse(data.withmissing$subjectnumber%in%ss.binfantis.no, 0,NA))
prop.table(table(data.withmissing$Binfantis.pre))
## 
##         0         1 
## 0.7462149 0.2537851
data.withmissing$BF <- ifelse(data.withmissing$bf_duration_imp>=3,1,0)

data.bf.plot <- data.frame(bf.prev=prop.table(with(data.withmissing, table(BF,site)),margin = 2)[2,])
data.bf.plot$Site <- rownames(data.bf.plot)
data.bf.plot$bf.prev <- data.bf.plot$bf.prev*100
library(Hmisc)
data.bf.plot$Site  <- capitalize(data.bf.plot$Site)
data.bf.plot$Site  <- factor(data.bf.plot$Site , levels=c("Vancouver","Edmonton" ,"Winnipeg" , "Toronto" ), ordered=T)
bfr.plot <- ggplot(data.bf.plot,aes(y=bf.prev, x=Site,fill = "#e76f51")) + 
  theme_bw() + 
  geom_bar(stat="identity") +
  geom_text(aes(label = paste0(round(bf.prev,0),"%")))+
  ylab("Breastfeeding rates (%)") + ggtitle("") +
  xlab("") + ylim(c(0,100))
bfr.plot

pdf("Figures/BF rate.pdf")
bfr.plot
dev.off()
## quartz_off_screen 
##                 2
used.vars.binfantis <- c(used.vars, "bfhistory_m","bfhistory_f")
used.vars.binfantis[used.vars.binfantis=="atbx.microbiome.new"] <- "atbx.1y"
used.vars.binfantis <- used.vars.binfantis[used.vars.binfantis!="bf"]
data.withmissing.bb <- data.withmissing

RES.bb.all <- NULL
for(used.var.binfantis in used.vars.binfantis){
  data.withmissing.bb$Var <- scale(as.numeric(as.character(data.withmissing.bb[,used.var.binfantis])))
  fit.bb <- glm(Binfantis.pre ~ Var + male + site,  family="binomial", subset(data.withmissing.bb,BF==1))
  coef.bb <- as.data.frame(summary(fit.bb)$coef)
  res.bb <- coef.bb[2,c("Estimate", "Pr(>|z|)"),drop=F]
  res.bb$low_ci <-  confint(fit.bb)[2,1]
  res.bb$high_ci <-  confint(fit.bb)[2,2]
  res.bb$Var <- used.var.binfantis
  RES.bb.all <- rbind(RES.bb.all, res.bb)
}
RES.bb.all$site <- "All"
RES.bb <- NULL

for(used.var.binfantis in used.vars.binfantis){
  for(site.use in unique(data.withmissing.bb$site)){
  data.withmissing.bb$Var <- scale(as.numeric(as.character(data.withmissing.bb[,used.var.binfantis])))
  fit.bb <- glm(Binfantis.pre ~ Var + male,  family="binomial", subset(data.withmissing.bb,BF==1 & site==site.use))
  coef.bb <- as.data.frame(summary(fit.bb)$coef)
  res.bb <- coef.bb[2,c("Estimate", "Pr(>|z|)"),drop=F]
  res.bb$low_ci <-  confint(fit.bb)[2,1]
  res.bb$high_ci <-  confint(fit.bb)[2,2]
  res.bb$Var <- used.var.binfantis
  res.bb$site <- site.use
  RES.bb <- rbind(RES.bb, res.bb)
  }
}
RES.bb.full <- rbind(RES.bb.all, RES.bb)
range(RES.bb.full$Estimate,na.rm=T)
## [1] -5.1302515  0.7938585
range(RES.bb.full$low_ci,na.rm=T)
## [1] -1.3185251  0.2094367
range(RES.bb.full$high_ci,na.rm=T)
## [1] -0.1417484 39.2997000
RES.bb.full[RES.bb.full$Estimate < -10,"high_ci"] <- NA
RES.bb.full[RES.bb.full$Estimate < -10,"Estimate"] <- NA
RES.bb.full[RES.bb.full$Estimate > 10& !is.na(RES.bb.full$Estimate) ,"low_ci"] <- NA
RES.bb.full[RES.bb.full$Estimate > 10 & !is.na(RES.bb.full$Estimate),"Estimate"] <- NA
# 
# RES.bb.full[RES.bb.full$high_ci >5,"Estimate"] <- NA 
# RES.bb.full[RES.bb.full$high_ci >5,"high_ci"] <- NA 

data.map[data.map$Vars=="bfhistory_m",]
##                    Vars              Category                             Label
## bfhistory_m bfhistory_m Breastfeeding history Mother was breastfed as an infant
##                    Type Values
## bfhistory_m Categorical   <NA>
RES.bb.use <- merge(RES.bb.full, data.map, by.x="Var", by.y="Vars",all.x=T)
RES.bb.use$Category <- factor(RES.bb.use$Category, levels=c("SES","Pregnancy",
                                                                          "Birth",
                                                                          "Postnatal",
                                                                          "Home Environment",
                                                                          "Neighbourhood Environment",
                                                                          "Parental Diet/Health","Breastfeeding history"),
                                     ordered=T)
RES.bb.use$U <- ifelse(RES.bb.use$`Pr(>|z|)`<0.05,"*","")

ff.plot <- ggplot(subset(RES.bb.use,  site=="All"), 
                     aes(x=reorder(Label,Estimate), y=exp(Estimate),alpha=U, fill=Category)) + 
  theme_bw() + 
  xlab("Coefficient") +
  geom_errorbar(aes(ymin=exp(low_ci),ymax=exp(high_ci)), width=.2, position=position_dodge(0.5)) +
  geom_point(position=position_dodge(0.5), size = 3, pch = 21) +
  facet_grid( ~ Category,scale="free",space="free_x") +
  xlab("") + ylab("Odds ratio on B. infantis presence in the first year of life") +
  scale_shape_manual(values=seq(0,10)) +
  scale_alpha_discrete(range = c(0.3,1))+
  geom_hline(yintercept=1,lty=2)+ 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+ 
  scale_fill_manual(values=c( "#8AB17D", "#E9C46A","#F4A261", "#E76F51", "#2A9D8F", "#287271", "#9A4770","black"))
 ff.plot

pdf("Figures/Binfantis factors.pdf",height=6, width=12)
 ff.plot
dev.off()
## quartz_off_screen 
##                 2

SEM model for SES -> Microbiome -> phenotype (Figure 5A)

# rm(list=ls())
# library(phyloseq)
# library(psych)
# library(corrplot)
# library("psych")
# library(ggplot2)
# library(car)
# library(magrittr)
# library(ggcorrplot)
# library(missForest)
# library(xlsx)
# library(WGCNA)
# library(ggpubr)
# library(lavaan)
# library(limma)
# library(metaMint)
# library(lubridate)
# library(Maaslin2)
# library(tidyverse)
# library(phyloseq)
# library(copiome)
# library(ggpubr)
# library(ggforce)
# library(patchwork)
# library(gtsummary)
# library(Maaslin2)
# library(plyr)
# library(ecodist)
# work.dir <- "/Users/darlene.dai/Desktop/SES/Results/manuscript/Code/"
# setwd(work.dir)
# load("/Users/darlene.dai/Desktop/SES/P0 Imputed data for factor analysis.RData")
# load("Results/P0 Clinical data with SES Index.RData")
# load("Results/P1 Processed Metagenomic data.RData")
# load("Results/P3 PCOA data.RData")
# load("Results/P2 Univariate Analysis of SES.Rdata")
# load("Results/P5 Maaslin2 sig ses species mclr.RData")
# source("/Users/darlene.dai/Desktop/SES/Script/P4 SEM update model.R")
# # load("Results/P4 SEM Res microbiome latent phenotype.RData")
# ########################################################################################################
# ses.res <- subset(UVA.res.outcome, Adj.genetic==F & SESVar=="MR1_latent.raw.interquartile" &
#                     !Variables%in%c("sitetoronto","sitevancouver","sitewinnipeg","male1") &
#                     Cohort=="all")
# 
# outcome.vars <-c("atopy5y", "asthma5y_ep", "overweight", "Tscore_abnormal")
# 
# 
# sig.use <- sig.sp.ses
# data.meta <- data.frame(sample_data(RBNME_species_MCLR))
# 
# 
# SampleID.3m<-rownames(subset(data.meta, Visit=="3 month"))
# SampleID.1y<-rownames(subset(data.meta, Visit=="1 year"))
# 
# data.sp <- data.frame(phyloseq::otu_table(phyloseq::subset_samples(RBNME_species_MCLR)))
# 
# data.sp.3m <- data.sp[SampleID.3m,sig.use]
# data.sp.1y <- data.sp[SampleID.1y,sig.use]
# 
# data.sp <- merge(merge(data.meta[,c("SampleID", "SubjectNumber")], data.sp.3m, by.x="SampleID", by.y="row.names"),
#                  merge(data.meta[,c("SampleID", "SubjectNumber")], data.sp.1y, by.x="SampleID", by.y="row.names"),
#                  by="SubjectNumber", all=T,suffixes = c(".3m", ".1y"))
# 
# for(sig.f in sig.use){
#   data.sp$sig.f <- (data.sp[,paste0(sig.f,".3m")] + data.sp[,paste0(sig.f,".1y")])/2
#   colnames(data.sp)[colnames(data.sp)=="sig.f"] <- paste0(sig.f,".overall")
#   data.sp$sig.f <- data.sp[,paste0(sig.f,".1y")] - data.sp[,paste0(sig.f,".3m")]
#   colnames(data.sp)[colnames(data.sp)=="sig.f"] <- paste0(sig.f,".change")
# }
# data.sem <- merge(data.withmissing, data.sp, by="subjectnumber", by.y="SubjectNumber",all.x=T)
# data.sem <- merge(data.sem, merge(data.div[data.div$Visit=="3 month",c("SubjectNumber", "Shannon.x","exact_age","ProcessingPeriod")],
#                                   data.div[data.div$Visit=="1 year",c("SubjectNumber", "Shannon.x","exact_age","ProcessingPeriod")],
#                                   by="SubjectNumber",suffixes = c(".3m",".1y"),all=T),
#                   by.x="subjectnumber", by.y="SubjectNumber",all.x=T)
# data.sem$exact_age.different <- data.sem$exact_age.1y-data.sem$exact_age.3m
# data.sem$exact_age.mean <- (data.sem$exact_age.1y+data.sem$exact_age.3m)/2
# data.sem$asthma5y_ep <- as.numeric(as.character(data.sem$asthma5y_ep ))
# data.sem$overweight <- as.numeric(as.character(data.sem$overweight ))
# data.sem$Tscore_abnormal <- as.numeric(as.character(data.sem$Tscore_abnormal ))
# data.sem$Shannon.x.change <- data.sem$Shannon.x.1y-data.sem$Shannon.x.3m
# data.sem.use <- data.sem[!is.na(data.sem$MR1_latent.raw),]
# 
# ####################################################################################
# sig.p.use <- unique(c("Bifidobacterium_longum.subsp.infantis",sig.use))
# used.l.sp <- c(paste0(sig.p.use  , ".3m"),paste0(sig.p.use, ".1y"))
# mm.latent <- c(paste("microbiome =~ ",paste(used.l.sp,collapse="+")))
# resp.check.vars <- c("overweight","asthma5y_ep","Tscore_abnormal","atopy5y")
# 
# tech.vars <- c("exact_age.3m","ProcessingPeriod.3m",
#                "ProcessingPeriod.1y","exact_age.1y",
#                "toronto", "edmonton", "vancouver","male")
# 
# m.ses <- paste('microbiome ~', "sesmm*MR1_latent.raw", "+",paste(tech.vars, collapse = " + "))
# m.main <- NULL
# m.test <- NULL
# for(resp.check.var in resp.check.vars){
#   cov.check.vars.all <- c("MR1_latent.raw", "microbiome")
#   m.main.i <- paste(resp.check.var,"~",
#                     paste(paste(paste0(resp.check.var,cov.check.vars.all),cov.check.vars.all, sep= "*"),collapse = " + "),
#                     "+", paste(tech.vars, collapse = " + "))
#   m.main <- c(m.main,m.main.i)
# 
#   m.test.i <- paste(paste0("ind_",resp.check.var)," := ",
#                     paste(paste0(resp.check.var, "microbiome"),"sesmm",sep="*"))
#   m.test.i.tt <- paste(paste0("total_",resp.check.var)," := ",
#                        paste(paste0(resp.check.var, "microbiome"),"sesmm",sep="*"),
#                        "+", paste0(resp.check.var,"MR1_latent.raw"))
#   m.test <- c(m.test,m.test.i,m.test.i.tt)
# }
# add.m <-  paste(paste0(sig.p.use  , ".3m"),"~~",paste0(sig.p.use, ".1y"))
# load("Results/SES_M_phenotype_sem_final.RData")
# add.m%in%adj.M.use.final
# data.sem.use$MR1_latent.raw <- data.sem.use$MR1_latent.raw.interquartile
# model.use <-paste(c(mm.latent, m.ses, m.main, m.test, adj.M.use.final),collapse = "\n")
# model.all <- sem(paste(model.use,sep="\n"),
#                  data=data.sem.use,
#                  ordered=c(resp.check.vars),
#                  missing="pairwise")
# 
# 
# ########################################################################################################################################################################
# model.serial.overweight <- sem(paste(c(c(mm.latent, m.ses, m.main[1], m.test[1:2]),adj.M.use.final),sep="\n"),
#                                data=data.sem.use,
#                                ordered=c(resp.check.vars),
#                                missing="pairwise")
# 
# model.serial.asthma <- sem(paste(c(c(mm.latent, m.ses, m.main[2], m.test[3:4]),adj.M.use.final),sep="\n"),
#                            data=data.sem.use,
#                            ordered=c(resp.check.vars),
#                            missing="pairwise")
# 
# model.serial.abnor <- sem(paste(c(c(mm.latent, m.ses, m.main[3], m.test[5:6]),adj.M.use.final),sep="\n"),
#                           data=data.sem.use,
#                           ordered=c(resp.check.vars),
#                           missing="pairwise")
# 
# model.serial.atopy <- sem(paste(c(c(mm.latent, m.ses, m.main[4], m.test[7:8]),adj.M.use.final),sep="\n"),
#                           data=data.sem.use,
#                           ordered=c(resp.check.vars),
#                           missing="pairwise")
# 
# ########################################################################################################################################################################
# model.serial.overweight.lw <- sem(paste(c(c(mm.latent, m.ses, m.main[1], m.test[1:2]),adj.M.use.final),sep="\n"),
#                                data=data.sem.use,
#                                ordered=c(resp.check.vars))
# 
# model.serial.asthma.lw <- sem(paste(c(c(mm.latent, m.ses, m.main[2], m.test[3:4]),adj.M.use.final),sep="\n"),
#                            data=data.sem.use,
#                            ordered=c(resp.check.vars))
# 
# model.serial.abnor.lw <- sem(paste(c(c(mm.latent, m.ses, m.main[3], m.test[5:6]),adj.M.use.final),sep="\n"),
#                           data=data.sem.use,
#                           ordered=c(resp.check.vars))
# 
# model.serial.atopy.lw <- sem(paste(c(c(mm.latent, m.ses, m.main[4], m.test[7:8]),adj.M.use.final),sep="\n"),
#                           data=data.sem.use,
#                           ordered=c(resp.check.vars))
# 
# save(model.all, adj.M.use.final,
#      model.serial.overweight, model.serial.asthma,
#      model.serial.abnor, model.serial.atopy,
#      model.serial.overweight.lw, model.serial.asthma.lw,
#      model.serial.abnor.lw, model.serial.atopy.lw,
#      file="Results/SES_M_phenotype_sem_final_seperate.RData")
# summary(model.all,fit=T,standardized=T)
# summary(model.serial.overweight,fit=T,standardized=T)
# summary(model.serial.asthma,fit=T,standardized=T)
# summary(model.serial.abnor,fit=T,standardized=T)
# summary(model.serial.atopy,fit=T,standardized=T)
# 
# summary(model.serial.overweight.lw,fit=T,standardized=T)
# summary(model.serial.asthma.lw,fit=T,standardized=T)
# summary(model.serial.abnor.lw,fit=T,standardized=T)
# summary(model.serial.atopy.lw,fit=T,standardized=T)

load("Results/SES_M_phenotype_sem_final_seperate.RData")
summary(model.all,fit=T,standardized=T)
## lavaan 0.6-19 ended normally after 652 iterations
## 
##   Estimator                                       DWLS
##   Optimization method                           NLMINB
##   Number of model parameters                       904
## 
##                                                   Used       Total
##   Number of observations                          1171        2752
##   Number of missing patterns                        14            
## 
## Model Test User Model:
##                                               Standard      Scaled
##   Test Statistic                              3265.727    2579.194
##   Degrees of freedom                              1812        1812
##   P-value (Chi-square)                           0.000       0.000
##   Scaling correction factor                                  1.920
##   Shift parameter                                          878.728
##     simple second-order correction                                
## 
## Model Test Baseline Model:
## 
##   Test statistic                             17090.948    8578.000
##   Degrees of freedom                              2016        2016
##   P-value                                        0.000       0.000
##   Scaling correction factor                                  2.297
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.904       0.883
##   Tucker-Lewis Index (TLI)                       0.893       0.870
##                                                                   
##   Robust Comparative Fit Index (CFI)                            NA
##   Robust Tucker-Lewis Index (TLI)                               NA
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.026       0.019
##   90 Percent confidence interval - lower         0.025       0.017
##   90 Percent confidence interval - upper         0.028       0.021
##   P-value H_0: RMSEA <= 0.050                    1.000       1.000
##   P-value H_0: RMSEA >= 0.080                    0.000       0.000
##                                                                   
##   Robust RMSEA                                                  NA
##   90 Percent confidence interval - lower                        NA
##   90 Percent confidence interval - upper                        NA
##   P-value H_0: Robust RMSEA <= 0.050                            NA
##   P-value H_0: Robust RMSEA >= 0.080                            NA
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.037       0.037
## 
## Parameter Estimates:
## 
##   Parameterization                               Delta
##   Standard errors                           Robust.sem
##   Information                                 Expected
##   Information saturated (h1) model        Unstructured
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   microbiome =~                                                         
##     Bfdbctrm_l...3    1.000                               0.206    0.053
##     Bct_.SGB1877.3   -0.233    0.152   -1.527    0.127   -0.048   -0.023
##     Bct_.SGB1855.3    0.233    0.274    0.852    0.394    0.048    0.014
##     Bct_.SGB1861.3   -0.037    0.176   -0.210    0.834   -0.008   -0.003
##     Bf_.SGB17278.3   -3.294    1.114   -2.958    0.003   -0.678   -0.267
##     Bf_.SGB17234.3   -2.262    0.874   -2.588    0.010   -0.465   -0.143
##     Cls_.SGB4037.3   -6.110    2.074   -2.947    0.003   -1.257   -0.459
##     C__C5_48.SGB47   -3.445    1.128   -3.055    0.002   -0.709   -0.473
##     Eg_.SGB14809.3   -4.584    1.603   -2.860    0.004   -0.943   -0.274
##     Ent_.SGB4760.3    4.312    1.433    3.009    0.003    0.887    0.580
##     Ent_.SGB7931.3    4.827    1.625    2.970    0.003    0.993    0.497
##     Ent_.SGB7962.3   -0.039    0.303   -0.129    0.897   -0.008   -0.002
##     Ebc_.SGB4933.3   -1.868    0.604   -3.094    0.002   -0.384   -0.397
##     Fc_.SGB15316.3   -1.288    0.461   -2.795    0.005   -0.265   -0.251
##     Hng_.SGB4742.3   -3.623    1.270   -2.854    0.004   -0.745   -0.350
##     Mdt_.SGB4563.3   -1.220    0.455   -2.682    0.007   -0.251   -0.175
##     Mgs_.SGB5868.3   -2.558    0.840   -3.047    0.002   -0.526   -0.462
##     Phc_.SGB1815.3    9.928    3.255    3.050    0.002    2.043    0.742
##     Phc_.SGB1814.3   -0.186    0.224   -0.832    0.406   -0.038   -0.013
##     Rt_.SGB16985.3    0.365    0.193    1.896    0.058    0.075    0.031
##     Rmn_.SGB4584.3   -5.481    1.918   -2.857    0.004   -1.128   -0.274
##     Rmn_.SGB4608.3   -0.541    0.279   -1.939    0.053   -0.111   -0.084
##     Rt_.SGB15271.3    1.327    0.501    2.650    0.008    0.273    0.140
##     Str_.SGB8065.3    0.058    0.253    0.229    0.819    0.012    0.003
##     Str_.SGB8168.3    1.329    0.535    2.485    0.013    0.273    0.129
##     Str_.SGB8084.3    0.278    0.169    1.643    0.100    0.057    0.027
##     Str_.SGB8005.3    0.203    0.250    0.813    0.416    0.042    0.012
##     St_.SGB8007_.3   -0.342    0.272   -1.260    0.208   -0.070   -0.022
##     Str_.SGB8002.3   -2.525    0.890   -2.836    0.005   -0.519   -0.220
##     Vll_.SGB6936.3   -0.087    0.152   -0.569    0.569   -0.018   -0.008
##     Bfdbctrm_l...1    1.763    0.579    3.042    0.002    0.363    0.095
##     Bct_.SGB1877.1   -0.294    0.225   -1.310    0.190   -0.061   -0.022
##     Bct_.SGB1855.1    0.401    0.356    1.125    0.261    0.083    0.022
##     Bct_.SGB1861.1   -0.801    0.375   -2.136    0.033   -0.165   -0.057
##     Bf_.SGB17278.1   -0.015    0.310   -0.049    0.961   -0.003   -0.001
##     Bf_.SGB17234.1    0.745    0.333    2.240    0.025    0.153    0.049
##     Cls_.SGB4037.1   -0.024    0.334   -0.072    0.943   -0.005   -0.001
##     C__C5_48.SGB47   -0.173    0.235   -0.735    0.463   -0.036   -0.011
##     Eg_.SGB14809.1    0.197    0.265    0.745    0.456    0.041    0.013
##     Ent_.SGB4760.1    4.588    1.560    2.941    0.003    0.944    0.422
##     Ent_.SGB7931.1    0.576    0.269    2.138    0.033    0.119    0.046
##     Ent_.SGB7962.1    4.199    1.386    3.030    0.002    0.864    0.425
##     Ebc_.SGB4933.1   -0.426    0.372   -1.145    0.252   -0.088   -0.024
##     Fc_.SGB15316.1   -0.476    0.379   -1.256    0.209   -0.098   -0.023
##     Hng_.SGB4742.1   -1.070    0.459   -2.330    0.020   -0.220   -0.076
##     Mdt_.SGB4563.1   -0.251    0.333   -0.754    0.451   -0.052   -0.015
##     Mgs_.SGB5868.1    1.759    0.677    2.600    0.009    0.362    0.140
##     Phc_.SGB1815.1   -0.216    0.270   -0.801    0.423   -0.044   -0.014
##     Phc_.SGB1814.1   -0.572    0.385   -1.486    0.137   -0.118   -0.031
##     Rt_.SGB16985.1    0.051    0.055    0.929    0.353    0.011    0.013
##     Rmn_.SGB4584.1  -15.197    4.963   -3.062    0.002   -3.127   -1.005
##     Rmn_.SGB4608.1   -1.884    0.780   -2.415    0.016   -0.388   -0.131
##     Rt_.SGB15271.1   -0.921    0.376   -2.453    0.014   -0.190   -0.064
##     Str_.SGB8065.1    0.191    0.150    1.273    0.203    0.039    0.020
##     Str_.SGB8168.1    1.516    0.517    2.931    0.003    0.312    0.532
##     Str_.SGB8084.1    1.031    0.384    2.687    0.007    0.212    0.263
##     Str_.SGB8005.1    1.228    0.611    2.008    0.045    0.253    0.080
##     St_.SGB8007_.1   -0.033    0.301   -0.109    0.913   -0.007   -0.002
##     Str_.SGB8002.1   -0.655    0.399   -1.642    0.101   -0.135   -0.033
##     Vll_.SGB6936.1    1.317    0.458    2.874    0.004    0.271    0.092
## 
## Regressions:
##                     Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   microbiome ~                                                           
##     MR1_lt. (ssmm)     0.021    0.009    2.495    0.013    0.104    0.074
##     exct_.3           -0.379    0.132   -2.873    0.004   -1.842   -0.170
##     PrcsP.3           -0.000    0.000   -0.163    0.870   -0.000   -0.003
##     PrcsP.1           -0.000    0.000   -0.419    0.676   -0.001   -0.007
##     exct_.1           -0.018    0.034   -0.522    0.602   -0.087   -0.009
##     toronto            0.017    0.013    1.341    0.180    0.083    0.037
##     edmontn            0.005    0.011    0.458    0.647    0.025    0.010
##     vancovr            0.033    0.015    2.276    0.023    0.161    0.070
##     male              -0.014    0.008   -1.659    0.097   -0.068   -0.034
##   overweight ~                                                           
##     MR1_lt. (oMR1)    -0.063    0.070   -0.904    0.366   -0.063   -0.044
##     microbm (ovrw)    -0.688    0.226   -3.042    0.002   -0.142   -0.139
##     exct_.3           -0.942    0.572   -1.646    0.100   -0.942   -0.085
##     PrcsP.3            0.001    0.003    0.259    0.796    0.001    0.011
##     PrcsP.1            0.000    0.003    0.080    0.936    0.000    0.003
##     exct_.1           -0.794    0.492   -1.614    0.106   -0.794   -0.082
##     toronto           -0.213    0.144   -1.481    0.139   -0.213   -0.092
##     edmontn            0.002    0.134    0.017    0.986    0.002    0.001
##     vancovr           -0.142    0.122   -1.164    0.245   -0.142   -0.061
##     male               0.085    0.090    0.946    0.344    0.085    0.042
##   asthma5y_ep ~                                                          
##     MR1_lt. (a5_M)    -0.116    0.090   -1.300    0.194   -0.116   -0.081
##     microbm (as5_)    -0.788    0.310   -2.541    0.011   -0.162   -0.159
##     exct_.3           -1.353    0.850   -1.591    0.112   -1.353   -0.123
##     PrcsP.3            0.005    0.003    1.369    0.171    0.005    0.076
##     PrcsP.1           -0.004    0.005   -0.899    0.368   -0.004   -0.055
##     exct_.1            0.028    0.572    0.048    0.961    0.028    0.003
##     toronto            0.142    0.192    0.739    0.460    0.142    0.062
##     edmontn            0.119    0.203    0.584    0.559    0.119    0.044
##     vancovr            0.246    0.162    1.524    0.128    0.246    0.105
##     male               0.174    0.126    1.373    0.170    0.174    0.085
##   Tscore_abnormal ~                                                      
##     MR1_lt. (T_MR)    -0.202    0.111   -1.819    0.069   -0.202   -0.137
##     microbm (Tsc_)    -4.795    1.521   -3.153    0.002   -0.987   -0.947
##     exct_.3           -3.051    0.819   -3.724    0.000   -3.051   -0.271
##     PrcsP.3            0.003    0.004    0.647    0.518    0.003    0.040
##     PrcsP.1           -0.001    0.005   -0.194    0.846   -0.001   -0.011
##     exct_.1            1.159    0.690    1.679    0.093    1.159    0.117
##     toronto            0.216    0.249    0.868    0.386    0.216    0.092
##     edmontn           -0.101    0.222   -0.453    0.651   -0.101   -0.037
##     vancovr            0.357    0.202    1.771    0.077    0.357    0.149
##     male               0.089    0.148    0.601    0.548    0.089    0.043
##   atopy5y ~                                                              
##     MR1_lt. (a5MR)    -0.061    0.067   -0.901    0.368   -0.061   -0.041
##     microbm (atp5)     0.138    0.108    1.282    0.200    0.028    0.027
##     exct_.3           -0.749    0.524   -1.429    0.153   -0.749   -0.066
##     PrcsP.3           -0.003    0.003   -1.022    0.307   -0.003   -0.042
##     PrcsP.1           -0.005    0.003   -1.585    0.113   -0.005   -0.069
##     exct_.1           -0.595    0.449   -1.325    0.185   -0.595   -0.060
##     toronto            0.690    0.138    4.990    0.000    0.690    0.290
##     edmontn            0.512    0.141    3.638    0.000    0.512    0.185
##     vancovr            0.553    0.123    4.477    0.000    0.553    0.228
##     male               0.281    0.089    3.154    0.002    0.281    0.133
## 
## Covariances:
##                                                  Estimate  Std.Err  z-value
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Cls_.SGB4037.1                                  0.690    0.299    2.309
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .C__C5_48.SGB47                                  0.964    0.169    5.709
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Ent_.SGB7931.1                                  0.545    0.136    3.998
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Ent_.SGB7962.1                                  0.384    0.215    1.782
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Mgs_.SGB5868.1                                  0.210    0.080    2.626
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Rt_.SGB16985.1                                 -0.058    0.048   -1.210
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Rmn_.SGB4584.1                                 -1.782    0.606   -2.941
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Rmn_.SGB4608.1                                  0.604    0.091    6.623
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Str_.SGB8065.1                                  0.083    0.188    0.440
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Str_.SGB8168.1                                 -0.003    0.034   -0.084
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Str_.SGB8084.1                                  0.059    0.040    1.499
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .Str_.SGB8005.1                                  0.973    0.320    3.038
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .St_.SGB8007_.1                                  0.265    0.315    0.842
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Str_.SGB8002.1                                  0.476    0.284    1.676
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Str_.SGB8084.1                                  0.660    0.132    4.983
##  .Rothia_mucilaginosa.SGB16985.1y ~~                                       
##    .Str_.SGB8084.1                                  0.279    0.020   14.245
##  .Streptococcus_mitis.SGB8168.1y ~~                                        
##    .Str_.SGB8084.1                                  0.064    0.017    3.797
##  .Streptococcus_lactarius.SGB8065.1y ~~                                    
##    .Str_.SGB8084.1                                  0.574    0.049   11.611
##  .Rothia_mucilaginosa.SGB16985.1y ~~                                       
##    .Str_.SGB8065.1                                  0.649    0.065    9.907
##    .Str_.SGB8168.1                                  0.050    0.006    7.981
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Rt_.SGB15271.3                                  0.438    0.047    9.373
##    .Rmn_.SGB4608.3                                  0.139    0.022    6.374
##  .Streptococcus_lactarius.SGB8065.1y ~~                                    
##    .Str_.SGB8005.1                                  2.911    0.341    8.526
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Rt_.SGB15271.3                                  0.567    0.064    8.880
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Phc_.SGB1815.1                                  4.678    0.571    8.197
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Str_.SGB8084.3                                  1.820    0.222    8.195
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Str_.SGB8002.3                                  0.140    0.033    4.231
##    .Str_.SGB8168.1                                  0.155    0.020    7.651
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Ent_.SGB4760.1                                 -0.102    0.119   -0.856
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Bct_.SGB1877.1                                  2.373    0.298    7.972
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Rmn_.SGB4584.1                                  4.393    0.516    8.521
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Str_.SGB8002.3                                  1.390    0.166    8.384
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Bct_.SGB1861.1                                  2.979    0.386    7.723
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Rt_.SGB15271.3                                  1.821    0.239    7.611
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Mdt_.SGB4563.3                                  0.047    0.018    2.591
##    .Fc_.SGB15316.3                                 -0.013    0.020   -0.674
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Rmn_.SGB4584.1                                  2.859    0.357    8.017
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Eg_.SGB14809.1                                  3.722    0.494    7.539
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Rmn_.SGB4608.3                                  0.654    0.096    6.781
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Bfdbctrm_l...1                                  5.888    0.789    7.466
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Phc_.SGB1814.3                                  1.564    0.216    7.256
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Str_.SGB8168.1                                  0.327    0.046    7.121
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Mgs_.SGB5868.3                                 -0.161    0.045   -3.573
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Phc_.SGB1814.1                                  4.961    0.699    7.101
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Str_.SGB8002.3                                  0.244    0.052    4.660
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Phc_.SGB1815.3                                  1.210    0.172    7.023
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Str_.SGB8084.3                                  1.498    0.212    7.080
##  .Rothia_mucilaginosa.SGB16985.1y ~~                                       
##    .Str_.SGB8005.1                                  0.736    0.111    6.635
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Str_.SGB8002.1                                  6.153    0.936    6.570
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Rt_.SGB15271.3                                  0.871    0.136    6.405
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Bct_.SGB1861.3                                  0.886    0.138    6.406
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .St_.SGB8007_.3                                 -3.831    0.594   -6.450
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Phc_.SGB1815.3                                  0.913    0.110    8.268
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Phc_.SGB1815.3                                  1.193    0.205    5.819
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Bct_.SGB1855.1                                  5.945    0.960    6.196
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Mdt_.SGB4563.1                                  0.829    0.139    5.975
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Hng_.SGB4742.1                                  2.043    0.329    6.201
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .St_.SGB8007_.3                                  1.399    0.227    6.168
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Hng_.SGB4742.1                                  1.667    0.274    6.074
##    .Rmn_.SGB4584.1                                  4.060    0.513    7.907
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .Str_.SGB8002.3                                  1.522    0.247    6.173
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Rt_.SGB16985.1                                  0.356    0.060    5.970
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Str_.SGB8005.3                                  2.090    0.344    6.068
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Str_.SGB8002.3                                  0.597    0.165    3.616
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Str_.SGB8065.1                                  0.536    0.094    5.691
##  .Streptococcus_lactarius.SGB8065.1y ~~                                    
##    .Str_.SGB8168.1                                  0.106    0.021    4.983
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Rt_.SGB15271.3                                  0.082    0.064    1.279
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Rt_.SGB15271.1                                  2.386    0.410    5.826
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Vll_.SGB6936.1                                  1.840    0.321    5.735
##  .Streptococcus_salivarius.SGB8007_group.1y ~~                             
##    .Vll_.SGB6936.1                                  2.089    0.367    5.689
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .St_.SGB8007_.3                                 -4.017    0.697   -5.765
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Ent_.SGB7962.1                                  0.431    0.053    8.195
##  .Ruminococcus_torques.SGB4608.1y ~~                                       
##    .Rt_.SGB15271.1                                  2.234    0.395    5.655
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Rmn_.SGB4608.3                                  0.075    0.016    4.773
##  .Streptococcus_salivarius.SGB8005.1y ~~                                   
##    .St_.SGB8007_.1                                 -2.130    0.398   -5.358
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Phc_.SGB1814.1                                  2.907    0.550    5.287
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Eg_.SGB14809.1                                  2.264    0.429    5.279
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Str_.SGB8002.3                                  1.004    0.152    6.598
##    .Rmn_.SGB4608.3                                  0.333    0.069    4.825
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Ent_.SGB4760.1                                  1.571    0.314    4.995
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Rt_.SGB15271.1                                  1.066    0.206    5.169
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rt_.SGB15271.3                                  1.660    0.310    5.352
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Rmn_.SGB4584.1                                 -1.934    0.393   -4.926
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Ent_.SGB7962.1                                  0.403    0.065    6.158
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Bf_.SGB17234.1                                  1.588    0.302    5.255
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Rt_.SGB15271.1                                  2.515    0.484    5.202
##    .St_.SGB8007_.1                                  2.213    0.429    5.157
##  .Rothia_mucilaginosa.SGB16985.1y ~~                                       
##    .Vll_.SGB6936.1                                  0.289    0.057    5.039
##  .Streptococcus_salivarius.SGB8005.1y ~~                                   
##    .Vll_.SGB6936.1                                  1.643    0.317    5.177
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Mdt_.SGB4563.1                                  2.795    0.556    5.023
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Str_.SGB8005.3                                  2.602    0.515    5.051
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Ebc_.SGB4933.3                                  0.474    0.060    7.864
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Phc_.SGB1815.1                                  1.849    0.373    4.962
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Mgs_.SGB5868.3                                  0.265    0.055    4.794
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Str_.SGB8005.1                                  1.390    0.278    4.996
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Str_.SGB8168.1                                 -0.223    0.047   -4.712
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Str_.SGB8168.1                                  0.112    0.021    5.445
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Bf_.SGB17234.3                                  0.863    0.190    4.539
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Ent_.SGB7931.1                                  1.313    0.269    4.887
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Rt_.SGB15271.3                                  0.588    0.111    5.296
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Phc_.SGB1814.3                                  0.984    0.199    4.935
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Rt_.SGB15271.3                                  1.372    0.282    4.858
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Ebc_.SGB4933.1                                  0.396    0.091    4.375
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Bct_.SGB1861.1                                  1.322    0.274    4.818
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Ent_.SGB4760.3                                  1.691    0.209    8.072
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Cls_.SGB4037.1                                  2.599    0.530    4.901
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .C__C5_48.SGB47                                 -0.404    0.118   -3.418
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Str_.SGB8065.3                                  2.355    0.487    4.837
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Str_.SGB8168.3                                  1.106    0.227    4.870
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Vll_.SGB6936.3                                  0.558    0.124    4.505
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Rmn_.SGB4608.1                                  1.883    0.408    4.620
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Vll_.SGB6936.3                                  0.620    0.120    5.145
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rmn_.SGB4584.3                                  2.063    0.485    4.250
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Str_.SGB8002.1                                  1.793    0.450    3.985
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .Rmn_.SGB4584.1                                  1.757    0.400    4.392
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Vll_.SGB6936.1                                  1.577    0.348    4.534
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Mgs_.SGB5868.3                                 -0.137    0.063   -2.178
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Bfdbctrm_l...1                                  2.155    0.459    4.694
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Phc_.SGB1814.1                                  2.080    0.452    4.596
##  .Streptococcus_salivarius.SGB8007_group.1y ~~                             
##    .Str_.SGB8002.1                                  2.244    0.491    4.568
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Str_.SGB8065.1                                  0.598    0.132    4.546
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Phc_.SGB1814.1                                  1.190    0.263    4.519
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .C__C5_48.SGB47                                  2.143    0.471    4.545
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .St_.SGB8007_.3                                 -1.392    0.306   -4.542
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Str_.SGB8005.1                                  1.123    0.247    4.549
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Rt_.SGB16985.1                                  0.212    0.047    4.490
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Rt_.SGB15271.3                                  0.263    0.057    4.620
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Ent_.SGB7931.3                                  1.781    0.323    5.519
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Fc_.SGB15316.3                                  0.371    0.059    6.261
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Bct_.SGB1861.3                                  1.094    0.257    4.264
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Phc_.SGB1814.3                                  0.384    0.089    4.293
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Ent_.SGB7931.1                                  1.266    0.300    4.215
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Rt_.SGB15271.3                                  0.210    0.044    4.785
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Rmn_.SGB4584.1                                  1.079    0.277    3.900
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Rmn_.SGB4584.3                                  1.800    0.338    5.328
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Str_.SGB8168.1                                  0.508    0.084    6.026
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Bct_.SGB1877.1                                  1.009    0.236    4.271
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Rmn_.SGB4608.1                                  1.519    0.357    4.250
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Str_.SGB8002.3                                  0.735    0.224    3.283
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Hng_.SGB4742.1                                  0.600    0.161    3.732
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rmn_.SGB4608.3                                  0.473    0.120    3.943
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Rt_.SGB15271.1                                  1.170    0.285    4.099
##  .Streptococcus_mitis.SGB8168.1y ~~                                        
##    .St_.SGB8007_.1                                  0.184    0.048    3.807
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Ent_.SGB7931.1                                  1.081    0.256    4.229
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Str_.SGB8005.1                                  1.204    0.303    3.979
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Hng_.SGB4742.3                                 -0.156    0.040   -3.876
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Str_.SGB8005.3                                  0.823    0.204    4.031
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Vll_.SGB6936.1                                  0.882    0.223    3.951
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Rmn_.SGB4608.3                                  0.563    0.143    3.928
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Rmn_.SGB4608.1                                  1.229    0.318    3.865
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Phc_.SGB1815.1                                  1.045    0.269    3.890
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Rmn_.SGB4608.1                                  0.470    0.197    2.386
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Mgs_.SGB5868.3                                 -0.098    0.059   -1.672
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Ebc_.SGB4933.3                                 -0.239    0.068   -3.525
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Mgs_.SGB5868.3                                  0.072    0.074    0.971
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Rmn_.SGB4584.3                                  1.768    0.286    6.190
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Rmn_.SGB4608.1                                  0.110    0.061    1.812
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Str_.SGB8084.3                                  0.839    0.220    3.807
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Hng_.SGB4742.1                                  1.082    0.276    3.918
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Bct_.SGB1861.1                                  1.154    0.263    4.390
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Str_.SGB8002.3                                  0.538    0.126    4.271
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Ent_.SGB4760.1                                  0.911    0.163    5.601
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Vll_.SGB6936.3                                  0.499    0.133    3.764
##  .Streptococcus_lactarius.SGB8065.1y ~~                                    
##    .St_.SGB8007_.1                                 -0.685    0.190   -3.600
##  .Ruthenibacterium_lactatiformans.SGB15271.1y ~~                           
##    .Vll_.SGB6936.1                                 -1.061    0.303   -3.500
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .St_.SGB8007_.1                                  1.139    0.315    3.622
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Rmn_.SGB4608.1                                  0.601    0.159    3.795
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Str_.SGB8002.1                                  1.464    0.402    3.641
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Fc_.SGB15316.1                                  2.248    0.626    3.591
##  .Phocaeicola_dorei.SGB1815.1y ~~                                          
##    .Phc_.SGB1814.1                                 -1.661    0.469   -3.539
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Rmn_.SGB4584.3                                  0.082    0.092    0.897
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Rmn_.SGB4608.3                                  0.074    0.027    2.801
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Ebc_.SGB4933.3                                 -0.009    0.048   -0.183
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Str_.SGB8005.1                                  1.220    0.351    3.478
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Ent_.SGB7931.1                                  0.796    0.227    3.509
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Mdt_.SGB4563.3                                  0.098    0.065    1.503
##  .Streptococcus_lactarius.SGB8065.1y ~~                                    
##    .Vll_.SGB6936.1                                  0.535    0.157    3.409
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Eg_.SGB14809.1                                  1.362    0.398    3.423
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Rmn_.SGB4608.1                                  0.423    0.170    2.493
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Vll_.SGB6936.3                                  0.119    0.038    3.161
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Str_.SGB8005.3                                  0.397    0.119    3.330
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Fc_.SGB15316.3                                  0.133    0.043    3.060
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Mdt_.SGB4563.1                                  1.498    0.486    3.081
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Str_.SGB8084.1                                  0.169    0.052    3.275
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Rmn_.SGB4584.3                                  3.102    0.531    5.846
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Ent_.SGB7931.3                                  1.537    0.246    6.260
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Str_.SGB8084.1                                 -0.235    0.068   -3.453
##    .Rmn_.SGB4584.1                                  2.899    0.406    7.133
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Str_.SGB8084.1                                 -0.423    0.105   -4.031
##    .Rmn_.SGB4584.1                                  6.174    0.825    7.485
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Str_.SGB8084.1                                  0.287    0.083    3.445
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Str_.SGB8168.1                                  0.968    0.163    5.954
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Str_.SGB8084.1                                 -0.191    0.051   -3.722
##    .Fc_.SGB15316.3                                  0.153    0.054    2.845
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Str_.SGB8084.1                                 -0.166    0.057   -2.887
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Ent_.SGB4760.1                                  1.677    0.364    4.605
##    .Str_.SGB8084.1                                  0.184    0.107    1.715
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Vll_.SGB6936.1                                  1.491    0.336    4.444
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Str_.SGB8084.1                                  0.150    0.051    2.925
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Hng_.SGB4742.3                                  0.910    0.154    5.897
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Ent_.SGB7931.3                                  0.854    0.152    5.618
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Rmn_.SGB4584.1                                  2.808    0.372    7.553
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Str_.SGB8084.1                                  0.113    0.060    1.894
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Str_.SGB8084.1                                  0.071    0.045    1.557
##    .Ent_.SGB7962.1                                  0.664    0.127    5.236
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Phc_.SGB1815.3                                  1.175    0.144    8.145
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Phc_.SGB1815.3                                  2.478    0.472    5.254
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Ent_.SGB7931.3                                 -0.834    0.145   -5.766
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Str_.SGB8084.1                                 -0.081    0.045   -1.788
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Rmn_.SGB4584.1                                 -0.782    0.191   -4.100
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Rt_.SGB15271.3                                  0.444    0.144    3.095
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Str_.SGB8084.1                                  0.202    0.081    2.482
##    .Ent_.SGB7962.1                                  1.324    0.220    6.012
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Str_.SGB8084.1                                  0.128    0.057    2.251
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Rmn_.SGB4584.1                                  2.254    0.362    6.217
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Ent_.SGB7962.1                                 -0.707    0.121   -5.852
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Ent_.SGB7962.1                                  0.763    0.144    5.290
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rmn_.SGB4584.1                                 -2.458    0.537   -4.577
##    .Ent_.SGB7962.1                                  1.108    0.262    4.231
##    .Ent_.SGB4760.1                                  1.319    0.304    4.341
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Rmn_.SGB4584.1                                 -1.670    0.295   -5.666
##    .Str_.SGB8084.1                                  0.071    0.082    0.866
##    .Str_.SGB8168.1                                  0.253    0.042    5.978
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Rmn_.SGB4584.1                                 -3.187    0.526   -6.055
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Str_.SGB8005.1                                  0.813    0.375    2.170
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Rmn_.SGB4584.1                                 -1.885    0.361   -5.222
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Rmn_.SGB4584.1                                 -1.124    0.149   -7.571
##    .Str_.SGB8084.1                                  0.067    0.026    2.622
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Str_.SGB8084.1                                  0.001    0.065    0.014
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Str_.SGB8084.1                                  0.014    0.061    0.237
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Rmn_.SGB4584.1                                  1.110    0.284    3.910
##    .Str_.SGB8084.1                                 -0.096    0.065   -1.482
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Str_.SGB8084.1                                 -0.012    0.045   -0.268
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Rmn_.SGB4584.1                                 -0.887    0.328   -2.703
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Str_.SGB8084.1                                  0.109    0.054    2.020
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Rmn_.SGB4584.1                                  1.527    0.362    4.218
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Ent_.SGB7962.1                                  0.996    0.286    3.478
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Rmn_.SGB4608.1                                  0.619    0.182    3.392
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Str_.SGB8084.1                                  0.112    0.037    2.995
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Vll_.SGB6936.1                                  0.743    0.248    2.996
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Bct_.SGB1861.1                                 -0.186    0.055   -3.358
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Rmn_.SGB4584.1                                 -1.603    0.489   -3.275
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Str_.SGB8084.1                                  0.040    0.025    1.603
##    .Rmn_.SGB4584.1                                 -0.756    0.173   -4.379
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Str_.SGB8084.1                                  0.007    0.039    0.189
##    .Rmn_.SGB4584.1                                 -0.197    0.145   -1.365
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Fc_.SGB15316.3                                 -0.242    0.077   -3.167
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Ebc_.SGB4933.1                                  0.655    0.208    3.148
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Ent_.SGB7931.3                                  0.739    0.111    6.645
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .St_.SGB8007_.3                                  0.818    0.280    2.922
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Str_.SGB8084.1                                 -0.100    0.055   -1.817
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Str_.SGB8168.3                                 -0.586    0.170   -3.457
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Str_.SGB8168.3                                  0.174    0.039    4.447
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Rmn_.SGB4584.1                                  0.714    0.275    2.596
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Vll_.SGB6936.1                                 -0.694    0.222   -3.123
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Fc_.SGB15316.1                                  0.514    0.176    2.918
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Ent_.SGB7962.1                                  0.639    0.153    4.174
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Cls_.SGB4037.1                                  0.969    0.344    2.819
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Bct_.SGB1861.1                                  0.471    0.159    2.971
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Bct_.SGB1877.1                                  0.515    0.174    2.966
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Ent_.SGB7962.1                                  0.150    0.080    1.861
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Phc_.SGB1814.1                                  1.183    0.411    2.878
##  .Phocaeicola_vulgatus.SGB1814.1y ~~                                       
##    .Rt_.SGB15271.1                                  1.065    0.362    2.944
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Bct_.SGB1861.1                                  0.412    0.157    2.624
##  .Ruminococcus_torques.SGB4608.1y ~~                                       
##    .Str_.SGB8084.1                                 -0.024    0.073   -0.323
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Ent_.SGB7962.1                                 -1.944    0.327   -5.940
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Fc_.SGB15316.3                                 -0.249    0.085   -2.926
##  .Phocaeicola_vulgatus.SGB1814.1y ~~                                       
##    .St_.SGB8007_.1                                  1.214    0.415    2.924
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Ent_.SGB7962.1                                  0.212    0.069    3.076
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Str_.SGB8065.3                                  1.199    0.415    2.891
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Fc_.SGB15316.3                                  0.103    0.039    2.659
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Ent_.SGB7962.1                                  0.477    0.072    6.609
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Str_.SGB8168.1                                  0.094    0.023    4.083
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Str_.SGB8168.1                                  0.357    0.077    4.620
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Str_.SGB8168.1                                 -0.282    0.053   -5.295
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Str_.SGB8168.1                                  0.392    0.072    5.447
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Str_.SGB8168.1                                  0.044    0.020    2.186
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Str_.SGB8168.1                                  0.130    0.043    3.057
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Str_.SGB8168.1                                  0.149    0.040    3.729
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Phc_.SGB1815.1                                  1.049    0.375    2.795
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Rmn_.SGB4608.1                                  1.081    0.392    2.758
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .St_.SGB8007_.1                                  1.100    0.395    2.785
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Rt_.SGB16985.1                                 -0.144    0.052   -2.780
##    .Phc_.SGB1814.1                                  1.067    0.382    2.790
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Str_.SGB8084.1                                  0.082    0.038    2.132
##    .Rmn_.SGB4584.1                                 -1.475    0.219   -6.732
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Str_.SGB8084.1                                  0.014    0.061    0.223
##  .Streptococcus_peroris.SGB8084.1y ~~                                      
##    .St_.SGB8007_.1                                  0.012    0.066    0.185
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Rmn_.SGB4608.1                                  0.663    0.234    2.835
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Phc_.SGB1814.3                                 -0.932    0.340   -2.744
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Rt_.SGB16985.3                                  0.216    0.082    2.641
##  .Phocaeicola_vulgatus.SGB1814.1y ~~                                       
##    .Rmn_.SGB4608.1                                  0.935    0.353    2.648
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Str_.SGB8005.1                                  0.127    0.049    2.569
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Ebc_.SGB4933.3                                  0.355    0.049    7.194
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Ent_.SGB4760.1                                  0.388    0.062    6.261
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Bct_.SGB1855.1                                  0.281    0.095    2.959
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Str_.SGB8084.1                                 -0.008    0.047   -0.169
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Mgs_.SGB5868.1                                  0.579    0.212    2.736
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Mgs_.SGB5868.1                                 -0.525    0.192   -2.737
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Rt_.SGB16985.1                                  0.151    0.056    2.717
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Str_.SGB8002.1                                  0.836    0.282    2.970
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Mgs_.SGB5868.1                                 -0.869    0.326   -2.666
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Fc_.SGB15316.3                                  0.186    0.060    3.076
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Rt_.SGB15271.1                                  0.537    0.217    2.474
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Phc_.SGB1815.3                                 -1.733    0.252   -6.874
##  .Rothia_mucilaginosa.SGB16985.1y ~~                                       
##    .St_.SGB8007_.1                                 -0.180    0.068   -2.666
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Bct_.SGB1855.1                                 -1.091    0.423   -2.582
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Fc_.SGB15316.1                                 -1.528    0.579   -2.639
##  .Streptococcus_peroris.SGB8084.1y ~~                                      
##    .Str_.SGB8002.1                                  0.138    0.085    1.624
##  .Streptococcus_mitis.SGB8168.1y ~~                                        
##    .Str_.SGB8002.1                                  0.155    0.053    2.924
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Ent_.SGB4760.1                                 -0.965    0.190   -5.065
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Ent_.SGB4760.1                                  1.205    0.239    5.035
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Rmn_.SGB4608.1                                  0.424    0.189    2.248
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Mdt_.SGB4563.1                                  0.148    0.066    2.249
##  .Veillonella_atypica.SGB6936.3m ~~                                        
##    .Str_.SGB8168.1                                  0.059    0.025    2.371
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Rt_.SGB15271.3                                  0.458    0.170    2.690
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Str_.SGB8168.3                                 -0.314    0.140   -2.245
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Phc_.SGB1814.1                                  0.652    0.256    2.546
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Rt_.SGB15271.1                                  0.734    0.288    2.546
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .C__C5_48.SGB47                                  0.905    0.337    2.683
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Phc_.SGB1814.1                                  1.408    0.538    2.618
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Bf_.SGB17278.1                                 -1.422    0.510   -2.789
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Ebc_.SGB4933.1                                  0.297    0.121    2.454
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Rmn_.SGB4584.1                                 -1.088    0.390   -2.792
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Rmn_.SGB4608.3                                 -0.103    0.043   -2.378
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Bf_.SGB17234.1                                  0.832    0.317    2.628
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Str_.SGB8168.1                                  0.092    0.057    1.617
##  .Ruminococcus_torques.SGB4608.1y ~~                                       
##    .Str_.SGB8168.1                                  0.139    0.048    2.927
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Cls_.SGB4037.1                                  0.201    0.221    0.909
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Mgs_.SGB5868.1                                 -0.906    0.356   -2.544
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .St_.SGB8007_.3                                  0.568    0.222    2.560
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .St_.SGB8007_.3                                  0.668    0.221    3.017
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .St_.SGB8007_.3                                  0.157    0.062    2.540
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Eg_.SGB14809.1                                  1.029    0.400    2.576
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Eg_.SGB14809.3                                  1.013    0.386    2.623
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Bct_.SGB1861.1                                  0.625    0.234    2.670
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Vll_.SGB6936.1                                 -0.532    0.220   -2.416
##  .Streptococcus_peroris.SGB8084.1y ~~                                      
##    .Vll_.SGB6936.1                                  0.073    0.057    1.273
##  .Veillonella_atypica.SGB6936.3m ~~                                        
##    .Vll_.SGB6936.1                                  0.411    0.169    2.436
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Vll_.SGB6936.1                                  0.755    0.315    2.399
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Fc_.SGB15316.1                                  0.987    0.389    2.539
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Phc_.SGB1815.1                                  0.789    0.315    2.503
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Ent_.SGB7962.1                                 -0.458    0.142   -3.221
##    .Mdt_.SGB4563.3                                  0.211    0.092    2.291
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Bct_.SGB1861.1                                  0.728    0.291    2.502
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Ebc_.SGB4933.1                                  0.720    0.290    2.482
##  .Phocaeicola_dorei.SGB1815.1y ~~                                          
##    .Rt_.SGB15271.1                                  0.711    0.278    2.554
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Ent_.SGB7962.1                                 -0.796    0.177   -4.498
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Ent_.SGB4760.1                                 -0.786    0.291   -2.704
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Ent_.SGB4760.1                                 -0.439    0.166   -2.651
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Mdt_.SGB4563.1                                 -0.979    0.396   -2.469
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Phc_.SGB1814.1                                  0.715    0.256    2.792
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Ent_.SGB4760.1                                  0.233    0.059    3.975
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Mdt_.SGB4563.3                                 -0.208    0.090   -2.314
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Bf_.SGB17278.1                                 -0.294    0.142   -2.062
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Mgs_.SGB5868.1                                  0.538    0.282    1.910
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Eg_.SGB14809.1                                 -0.426    0.175   -2.439
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Rt_.SGB15271.1                                  0.651    0.257    2.529
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Mgs_.SGB5868.1                                 -0.758    0.324   -2.339
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .St_.SGB8007_.1                                 -0.657    0.250   -2.627
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Phc_.SGB1815.3                                 -0.749    0.342   -2.193
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Bf_.SGB17234.1                                 -0.556    0.235   -2.370
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Bf_.SGB17234.1                                  0.154    0.052    2.974
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Rmn_.SGB4584.1                                  0.514    0.297    1.727
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .Str_.SGB8168.1                                  0.110    0.043    2.566
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Eg_.SGB14809.1                                  0.668    0.275    2.433
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Mdt_.SGB4563.1                                  0.425    0.176    2.418
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Rt_.SGB15271.1                                  0.594    0.240    2.477
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Ebc_.SGB4933.1                                 -0.674    0.262   -2.573
##  .Ruminococcus_torques.SGB4608.1y ~~                                       
##    .St_.SGB8007_.1                                  0.857    0.313    2.742
##  .Phocaeicola_dorei.SGB1815.1y ~~                                          
##    .St_.SGB8007_.1                                  0.817    0.334    2.447
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Bf_.SGB17234.1                                 -0.715    0.296   -2.413
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Rmn_.SGB4584.1                                 -1.973    0.283   -6.961
##    .Str_.SGB8084.1                                  0.133    0.073    1.825
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Str_.SGB8005.1                                 -0.191    0.190   -1.004
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Str_.SGB8168.1                                  0.059    0.022    2.651
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Str_.SGB8002.3                                  0.570    0.239    2.383
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Bct_.SGB1877.1                                  0.505    0.205    2.467
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Phc_.SGB1815.3                                 -1.732    0.292   -5.925
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Phc_.SGB1815.3                                  1.542    0.271    5.685
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Phc_.SGB1815.3                                  0.558    0.140    3.986
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Phc_.SGB1815.3                                  2.364    0.395    5.989
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Phc_.SGB1815.3                                  1.339    0.282    4.748
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Ent_.SGB4760.1                                 -1.964    0.321   -6.112
##    .Bfdbctrm_l...1                                 -1.195    0.391   -3.053
##    .Str_.SGB8002.3                                  0.964    0.256    3.766
##    .Vll_.SGB6936.1                                 -0.767    0.279   -2.746
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Phc_.SGB1815.3                                  0.521    0.122    4.287
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Str_.SGB8168.1                                 -0.554    0.115   -4.828
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Fc_.SGB15316.3                                 -0.229    0.068   -3.369
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Rt_.SGB15271.3                                 -0.772    0.247   -3.128
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Str_.SGB8065.3                                 -1.179    0.405   -2.908
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Mgs_.SGB5868.1                                  0.691    0.262    2.637
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Ent_.SGB4760.1                                  0.505    0.185    2.733
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Mgs_.SGB5868.1                                  0.635    0.252    2.522
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .St_.SGB8007_.3                                  1.036    0.389    2.665
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Vll_.SGB6936.1                                  0.779    0.306    2.544
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Phc_.SGB1815.1                                 -0.785    0.336   -2.341
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Str_.SGB8005.3                                  0.456    0.188    2.422
##  .Phocaeicola_dorei.SGB1815.1y ~~                                          
##    .Str_.SGB8005.1                                 -0.833    0.351   -2.373
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .St_.SGB8007_.1                                  0.755    0.300    2.516
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Fc_.SGB15316.1                                  1.037    0.442    2.347
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Eg_.SGB14809.1                                  0.677    0.291    2.330
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Bct_.SGB1877.1                                  0.181    0.089    2.023
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .St_.SGB8007_.1                                  1.050    0.426    2.463
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Phc_.SGB1815.1                                  0.823    0.353    2.330
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Hng_.SGB4742.1                                 -0.891    0.353   -2.520
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Rt_.SGB15271.1                                  0.249    0.092    2.712
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Rt_.SGB15271.1                                  0.890    0.365    2.442
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Rmn_.SGB4608.1                                 -0.820    0.334   -2.454
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Rmn_.SGB4584.3                                  0.538    0.240    2.246
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Mdt_.SGB4563.1                                 -0.668    0.294   -2.268
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Vll_.SGB6936.1                                 -0.890    0.392   -2.269
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Mdt_.SGB4563.1                                  0.407    0.183    2.227
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Rt_.SGB15271.1                                 -0.600    0.266   -2.256
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Rt_.SGB15271.1                                  0.869    0.360    2.412
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Str_.SGB8084.1                                 -0.103    0.076   -1.345
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Ent_.SGB7962.3                                  1.019    0.428    2.383
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Ebc_.SGB4933.1                                 -0.468    0.276   -1.695
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Ebc_.SGB4933.1                                 -0.649    0.300   -2.168
##  .Phocaeicola_dorei.SGB1815.1y ~~                                          
##    .Str_.SGB8002.1                                 -0.859    0.381   -2.252
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Str_.SGB8065.3                                 -1.194    0.463   -2.577
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .Phc_.SGB1815.1                                  0.687    0.304    2.260
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .Eg_.SGB14809.1                                  0.748    0.323    2.320
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .Rmn_.SGB4608.1                                 -0.307    0.414   -0.741
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Str_.SGB8168.1                                 -0.184    0.043   -4.233
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Str_.SGB8168.1                                  0.094    0.044    2.135
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Str_.SGB8168.1                                  0.187    0.055    3.403
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Vll_.SGB6936.3                                  0.058    0.024    2.406
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .St_.SGB8007_.1                                  0.300    0.208    1.443
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Phc_.SGB1814.1                                  0.096    0.064    1.488
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .Ebc_.SGB4933.1                                 -0.883    0.392   -2.254
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .St_.SGB8007_.1                                  0.636    0.278    2.286
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Rt_.SGB16985.3                                 -0.488    0.219   -2.223
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Phc_.SGB1814.3                                 -1.049    0.466   -2.252
##  .Enterococcus_faecalis.SGB7962.3m ~~                                      
##    .Ebc_.SGB4933.3                                 -0.129    0.060   -2.143
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Mdt_.SGB4563.1                                  0.404    0.175    2.317
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Fc_.SGB15316.1                                 -0.916    0.417   -2.194
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Str_.SGB8005.3                                  0.739    0.338    2.186
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Vll_.SGB6936.3                                  0.254    0.116    2.183
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rt_.SGB15271.1                                  0.747    0.304    2.458
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Cls_.SGB4037.1                                  0.434    0.148    2.935
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Phc_.SGB1815.3                                  1.378    0.204    6.768
##    .Ent_.SGB7962.1                                  0.575    0.104    5.532
##    .Ent_.SGB4760.3                                  0.610    0.096    6.352
##    .Ent_.SGB4760.1                                  0.679    0.120    5.650
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Mgs_.SGB5868.3                                  0.450    0.089    5.075
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Mgs_.SGB5868.3                                 -0.575    0.105   -5.496
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Ent_.SGB7931.1                                  0.110    0.058    1.901
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .St_.SGB8007_.3                                  0.244    0.103    2.364
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Phc_.SGB1814.3                                  0.770    0.312    2.463
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Str_.SGB8168.1                                 -0.224    0.052   -4.293
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Str_.SGB8005.1                                 -0.453    0.309   -1.466
##    .Str_.SGB8168.3                                 -0.470    0.226   -2.078
##    .Mgs_.SGB5868.1                                 -0.771    0.277   -2.779
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Str_.SGB8168.1                                 -0.118    0.049   -2.428
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Mgs_.SGB5868.1                                 -0.328    0.178   -1.839
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Bf_.SGB17278.1                                  0.768    0.276    2.782
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Rmn_.SGB4584.3                                 -0.802    0.320   -2.503
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Fc_.SGB15316.3                                 -0.084    0.084   -1.007
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Vll_.SGB6936.3                                  0.251    0.109    2.296
##  .Phocaeicola_vulgatus.SGB1814.3m ~~                                       
##    .Rmn_.SGB4584.3                                  0.815    0.345    2.362
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Phc_.SGB1815.1                                  0.442    0.210    2.108
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Fc_.SGB15316.1                                 -0.900    0.385   -2.339
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Cls_.SGB4037.1                                  1.328    0.468    2.835
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .C__C5_48.SGB47                                  0.762    0.347    2.194
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Bfdbctrm_l...1                                 -0.383    0.251   -1.523
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Bf_.SGB17234.1                                  0.393    0.182    2.160
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Vll_.SGB6936.1                                 -0.668    0.343   -1.948
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Bfdbctrm_l...1                                 -0.664    0.312   -2.130
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Str_.SGB8005.1                                 -0.622    0.284   -2.188
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Mgs_.SGB5868.1                                 -0.619    0.310   -1.997
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Cls_.SGB4037.1                                 -0.430    0.212   -2.032
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Str_.SGB8005.3                                  0.372    0.179    2.073
##  .Ruminococcus_torques.SGB4608.1y ~~                                       
##    .Vll_.SGB6936.1                                 -0.692    0.293   -2.366
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Phc_.SGB1815.3                                  0.983    0.330    2.976
##    .Ent_.SGB7931.3                                  0.376    0.204    1.844
##    .Fc_.SGB15316.3                                 -0.186    0.075   -2.478
##    .Ent_.SGB4760.1                                  0.561    0.216    2.598
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Ent_.SGB4760.1                                  0.194    0.118    1.634
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Ent_.SGB4760.1                                  0.557    0.178    3.135
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Rmn_.SGB4608.1                                  0.377    0.205    1.843
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Ent_.SGB4760.1                                  0.471    0.090    5.250
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Str_.SGB8005.1                                 -0.372    0.240   -1.552
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Ent_.SGB4760.1                                  0.055    0.097    0.569
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Mgs_.SGB5868.1                                 -0.258    0.174   -1.482
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Rmn_.SGB4608.1                                  0.476    0.302    1.578
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Bct_.SGB1861.1                                  0.717    0.288    2.491
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Str_.SGB8005.1                                  0.146    0.112    1.307
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Str_.SGB8168.1                                  0.195    0.041    4.788
##    .Hng_.SGB4742.3                                 -0.499    0.091   -5.480
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Str_.SGB8168.1                                 -0.129    0.053   -2.427
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Bf_.SGB17278.1                                  0.697    0.272    2.559
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Phc_.SGB1814.1                                  0.862    0.468    1.841
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Phc_.SGB1814.1                                 -0.467    0.356   -1.311
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Fc_.SGB15316.1                                  0.581    0.274    2.122
##  .Hungatella_hathewayi.SGB4742.3m ~~                                       
##    .Str_.SGB8005.3                                  0.367    0.190    1.935
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Rt_.SGB15271.1                                 -0.405    0.193   -2.102
##    .Rt_.SGB16985.3                                 -0.455    0.222   -2.053
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Bfdbctrm_l...1                                 -1.020    0.500   -2.038
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Mdt_.SGB4563.1                                 -0.764    0.368   -2.075
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Str_.SGB8002.1                                 -0.239    0.131   -1.820
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Bfdbctrm_l...1                                 -0.960    0.465   -2.062
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .Bfdbctrm_l...1                                  0.745    0.356    2.093
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .C__C5_48.SGB47                                 -0.692    0.342   -2.025
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Hng_.SGB4742.1                                 -0.153    0.073   -2.098
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Hng_.SGB4742.1                                 -0.097    0.069   -1.402
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Cls_.SGB4037.1                                 -0.929    0.402   -2.308
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Phc_.SGB1815.1                                  0.335    0.165    2.028
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Ebc_.SGB4933.3                                 -0.184    0.073   -2.535
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Rt_.SGB15271.1                                 -0.444    0.218   -2.033
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Vll_.SGB6936.3                                  0.277    0.123    2.250
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Vll_.SGB6936.3                                  0.116    0.066    1.763
##  .Mediterraneibacter_faecis.SGB4563.1y ~~                                  
##    .Vll_.SGB6936.1                                 -0.694    0.340   -2.045
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Fc_.SGB15316.1                                 -0.877    0.424   -2.066
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Ent_.SGB7962.1                                 -0.069    0.131   -0.526
##  .Bacteroides_fragilis.SGB1855.3m ~~                                       
##    .Phc_.SGB1815.3                                  0.465    0.285    1.628
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Bct_.SGB1877.1                                  0.173    0.080    2.170
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .Rt_.SGB15271.1                                  0.389    0.194    1.999
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Ent_.SGB4760.1                                  0.289    0.182    1.590
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Str_.SGB8065.3                                 -0.726    0.357   -2.034
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Bf_.SGB17234.1                                 -0.728    0.333   -2.188
##  .Phocaeicola_vulgatus.SGB1814.1y ~~                                       
##    .Str_.SGB8065.1                                  0.435    0.216    2.010
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Mdt_.SGB4563.1                                  0.522    0.265    1.969
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Bct_.SGB1861.1                                 -0.652    0.319   -2.045
##    .Str_.SGB8005.1                                  0.672    0.326    2.063
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Ebc_.SGB4933.1                                  0.175    0.108    1.623
##  .Enterococcus_faecalis.SGB7962.1y ~~                                      
##    .Ebc_.SGB4933.1                                 -0.240    0.232   -1.033
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Rt_.SGB15271.3                                  0.216    0.103    2.099
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Eg_.SGB14809.1                                 -0.355    0.186   -1.905
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Eg_.SGB14809.1                                  0.293    0.139    2.111
##    .Ebc_.SGB4933.3                                 -0.264    0.048   -5.561
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Rt_.SGB15271.1                                 -0.720    0.368   -1.956
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Rt_.SGB15271.1                                  0.758    0.380    1.992
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Bfdbctrm_l...1                                  0.427    0.212    2.013
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .St_.SGB8007_.1                                  0.679    0.331    2.049
##  .Bacteroides_caccae.SGB1877.3m ~~                                         
##    .Bct_.SGB1855.3                                  0.378    0.187    2.017
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Fc_.SGB15316.1                                 -0.253    0.195   -1.294
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .Str_.SGB8002.1                                 -0.937    0.469   -1.997
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Mdt_.SGB4563.1                                 -0.786    0.398   -1.973
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Fc_.SGB15316.1                                 -0.679    0.341   -1.989
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .Str_.SGB8065.1                                  0.332    0.176    1.883
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Bct_.SGB1861.1                                  0.663    0.321    2.065
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Str_.SGB8065.3                                 -0.712    0.312   -2.279
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Str_.SGB8002.3                                  1.070    0.127    8.423
##    .Mdt_.SGB4563.3                                  0.403    0.062    6.481
##    .Hng_.SGB4742.3                                  0.864    0.126    6.848
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Ent_.SGB4760.3                                  0.841    0.122    6.919
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Ent_.SGB4760.3                                  1.601    0.258    6.206
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Rmn_.SGB4608.3                                  0.260    0.054    4.850
##    .Mgs_.SGB5868.3                                  0.495    0.067    7.367
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Str_.SGB8065.3                                  4.127    0.575    7.177
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Hng_.SGB4742.1                                  3.459    0.514    6.734
##  .Streptococcus_peroris.SGB8084.1y ~~                                      
##    .Str_.SGB8005.1                                  0.610    0.086    7.065
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .Vll_.SGB6936.3                                  1.327    0.205    6.469
##  .Megasphaera_micronuciformis.SGB5868.1y ~~                                
##    .Vll_.SGB6936.1                                  2.077    0.319    6.519
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Vll_.SGB6936.3                                  0.271    0.049    5.575
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Rt_.SGB16985.3                                  1.700    0.295    5.757
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Mgs_.SGB5868.1                                  1.636    0.286    5.723
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Str_.SGB8168.3                                  0.898    0.161    5.563
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Str_.SGB8002.1                                  2.958    0.551    5.365
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Bfdbctrm_l...1                                  1.565    0.286    5.473
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Phc_.SGB1814.3                                  0.434    0.076    5.688
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Rmn_.SGB4608.1                                  0.660    0.148    4.451
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Rmn_.SGB4584.1                                  1.652    0.315    5.242
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Fc_.SGB15316.3                                 -0.021    0.036   -0.567
##  .Ruminococcus_gnavus.SGB4584.1y ~~                                        
##    .St_.SGB8007_.1                                  1.890    0.382    4.946
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Str_.SGB8168.1                                  0.141    0.030    4.731
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Mgs_.SGB5868.3                                 -0.123    0.025   -4.846
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Mdt_.SGB4563.3                                  0.071    0.021    3.370
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Str_.SGB8002.3                                 -0.198    0.052   -3.801
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Str_.SGB8084.3                                  1.052    0.233    4.518
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Str_.SGB8168.1                                  0.088    0.024    3.697
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Rmn_.SGB4584.1                                  1.949    0.444    4.389
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Str_.SGB8168.3                                 -0.388    0.120   -3.227
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Rmn_.SGB4608.3                                  0.309    0.061    5.059
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Mgs_.SGB5868.3                                 -0.268    0.105   -2.540
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Str_.SGB8084.1                                  0.157    0.035    4.510
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Ent_.SGB4760.3                                  0.489    0.162    3.011
##  .Clostridium_sp_C5_48.SGB4752.3m ~~                                       
##    .Rt_.SGB15271.3                                  0.361    0.070    5.168
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .Ent_.SGB4760.1                                  0.815    0.217    3.762
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Rmn_.SGB4608.1                                  1.443    0.371    3.889
##  .Ruthenibacterium_lactatiformans.SGB15271.1y ~~                           
##    .St_.SGB8007_.1                                  1.285    0.344    3.738
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Mgs_.SGB5868.1                                  0.716    0.188    3.816
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Str_.SGB8002.3                                  1.464    0.294    4.981
##  .Enterocloster_clostridioformis.SGB4760.1y ~~                             
##    .St_.SGB8007_.1                                  0.875    0.248    3.528
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Mdt_.SGB4563.1                                 -1.373    0.388   -3.542
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Mgs_.SGB5868.3                                 -0.121    0.041   -2.982
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Hng_.SGB4742.1                                 -1.393    0.394   -3.535
##  .Veillonella_atypica.SGB6936.3m ~~                                        
##    .Mgs_.SGB5868.1                                  0.480    0.136    3.534
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Rmn_.SGB4584.3                                  1.593    0.371    4.295
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Ebc_.SGB4933.3                                 -0.022    0.036   -0.608
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Mgs_.SGB5868.3                                 -0.089    0.027   -3.319
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Mgs_.SGB5868.1                                 -0.434    0.174   -2.496
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Rmn_.SGB4608.1                                 -0.287    0.101   -2.833
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Rmn_.SGB4584.3                                  0.994    0.275    3.617
##  .Streptococcus_salivarius.SGB8005.3m ~~                                   
##    .Vll_.SGB6936.3                                  0.656    0.191    3.440
##  .Clostridium_sp_C5_48.SGB4752.1y ~~                                       
##    .Hng_.SGB4742.1                                  1.031    0.303    3.399
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Vll_.SGB6936.1                                 -0.452    0.142   -3.176
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Str_.SGB8065.1                                  0.552    0.164    3.357
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Hng_.SGB4742.1                                  0.738    0.218    3.389
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Bct_.SGB1877.1                                  0.455    0.137    3.329
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Phc_.SGB1814.3                                  0.130    0.039    3.346
##  .Streptococcus_salivarius.SGB8007_group.3m ~~                             
##    .Bfdbctrm_l...1                                 -1.359    0.407   -3.336
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Str_.SGB8005.1                                  0.642    0.193    3.320
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Hng_.SGB4742.1                                  1.155    0.346    3.342
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Hng_.SGB4742.3                                  0.408    0.119    3.412
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Ebc_.SGB4933.1                                 -1.413    0.428   -3.303
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Rmn_.SGB4584.3                                 -1.951    0.610   -3.197
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Eg_.SGB14809.3                                  0.842    0.250    3.372
##  .Clostridium_innocuum.SGB4037.1y ~~                                       
##    .Fc_.SGB15316.1                                 -1.722    0.526   -3.276
##  .Bacteroides_thetaiotaomicron.SGB1861.3m ~~                               
##    .Phc_.SGB1814.1                                  0.892    0.273    3.265
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Eg_.SGB14809.1                                  1.330    0.408    3.261
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Str_.SGB8065.1                                  0.412    0.127    3.250
##  .Bacteroides_thetaiotaomicron.SGB1861.1y ~~                               
##    .Rt_.SGB15271.1                                  0.838    0.260    3.231
##  .Bifidobacterium_animalis.SGB17278.1y ~~                                  
##    .Hng_.SGB4742.1                                  1.204    0.371    3.246
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Fc_.SGB15316.1                                  1.917    0.590    3.249
##  .Eggerthella_lenta.SGB14809.1y ~~                                         
##    .Ent_.SGB4760.1                                  0.771    0.233    3.311
##  .Eubacterium_rectale.SGB4933.1y ~~                                        
##    .Rmn_.SGB4584.1                                 -1.527    0.424   -3.600
##  .Ruthenibacterium_lactatiformans.SGB15271.3m ~~                           
##    .Phc_.SGB1814.1                                  0.697    0.214    3.259
##  .Bacteroides_caccae.SGB1877.1y ~~                                         
##    .Fc_.SGB15316.1                                  1.207    0.377    3.202
##  .Faecalibacterium_prausnitzii.SGB15316.1y ~~                              
##    .Phc_.SGB1815.1                                  1.503    0.473    3.177
##  .Streptococcus_mitis.SGB8168.1y ~~                                        
##    .Str_.SGB8005.1                                  0.155    0.045    3.423
##  .Bifidobacterium_longum.subsp.infantis.1y ~~                              
##    .St_.SGB8007_.1                                 -1.294    0.413   -3.131
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .St_.SGB8007_.3                                 -1.334    0.428   -3.118
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Mdt_.SGB4563.1                                 -1.061    0.341   -3.113
##  .Ruminococcus_gnavus.SGB4584.3m ~~                                        
##    .Bct_.SGB1877.1                                  1.059    0.340    3.117
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Bct_.SGB1877.1                                  0.165    0.054    3.044
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Bct_.SGB1861.1                                  0.296    0.120    2.470
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Rt_.SGB16985.3                                 -0.894    0.281   -3.182
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Vll_.SGB6936.3                                 -0.240    0.078   -3.093
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Str_.SGB8005.3                                  1.146    0.374    3.063
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Str_.SGB8168.3                                 -0.949    0.239   -3.970
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Ent_.SGB7962.1                                  0.398    0.135    2.943
##  .Ruminococcus_torques.SGB4608.3m ~~                                       
##    .Bct_.SGB1861.1                                  0.210    0.071    2.970
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Rt_.SGB15271.3                                  0.127    0.047    2.723
##  .Eubacterium_rectale.SGB4933.3m ~~                                        
##    .Rmn_.SGB4584.3                                 -0.192    0.091   -2.104
##  .Megasphaera_micronuciformis.SGB5868.3m ~~                                
##    .Rmn_.SGB4584.3                                 -0.211    0.119   -1.778
##  .Mediterraneibacter_faecis.SGB4563.3m ~~                                  
##    .Rmn_.SGB4584.3                                 -0.231    0.152   -1.516
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Hng_.SGB4742.3                                 -0.086    0.046   -1.857
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Bfdbctrm_l...1                                 -0.369    0.181   -2.041
##    .Str_.SGB8005.1                                 -0.387    0.196   -1.977
##  .Phocaeicola_dorei.SGB1815.3m ~~                                          
##    .Ebc_.SGB4933.1                                  0.680    0.316    2.153
##  .Bifidobacterium_longum.subsp.infantis.3m ~~                              
##    .Phc_.SGB1815.3                                 -0.827    0.383   -2.159
##  .Enterocloster_clostridioformis.SGB4760.3m ~~                             
##    .Hng_.SGB4742.1                                  0.282    0.143    1.965
##    .Rt_.SGB15271.1                                  0.238    0.119    2.007
##  .Streptococcus_thermophilus.SGB8002.3m ~~                                 
##    .Cls_.SGB4037.1                                  0.590    0.255    2.316
##  .Phocaeicola_vulgatus.SGB1814.1y ~~                                       
##    .Str_.SGB8168.1                                  0.113    0.051    2.199
##  .Eggerthella_lenta.SGB14809.3m ~~                                         
##    .Hng_.SGB4742.3                                  0.894    0.215    4.162
##    .Cls_.SGB4037.1                                  0.829    0.376    2.203
##  .Bifidobacterium_dentium.SGB17234.1y ~~                                   
##    .Str_.SGB8084.1                                  0.117    0.052    2.277
##  .Hungatella_hathewayi.SGB4742.1y ~~                                       
##    .Str_.SGB8002.1                                  0.761    0.357    2.131
##  .Enterococcus_avium.SGB7931.1y ~~                                         
##    .Rmn_.SGB4608.1                                 -0.509    0.240   -2.119
##  .Clostridium_innocuum.SGB4037.3m ~~                                       
##    .Ent_.SGB7962.3                                 -0.622    0.313   -1.989
##  .Bacteroides_fragilis.SGB1855.1y ~~                                       
##    .Rmn_.SGB4584.1                                  0.975    0.427    2.280
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Str_.SGB8065.3                                 -0.636    0.311   -2.044
##  .Rothia_mucilaginosa.SGB16985.3m ~~                                       
##    .Cls_.SGB4037.1                                 -0.508    0.253   -2.006
##  .Enterococcus_avium.SGB7931.3m ~~                                         
##    .Bct_.SGB1855.1                                 -0.514    0.262   -1.964
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .St_.SGB8007_.1                                  0.505    0.248    2.040
##  .Streptococcus_lactarius.SGB8065.3m ~~                                    
##    .Str_.SGB8002.3                                 -0.532    0.269   -1.975
##  .Streptococcus_peroris.SGB8084.3m ~~                                      
##    .Vll_.SGB6936.1                                  0.340    0.177    1.928
##  .Faecalibacterium_prausnitzii.SGB15316.3m ~~                              
##    .Bct_.SGB1861.1                                  0.111    0.054    2.047
##  .Bifidobacterium_animalis.SGB17278.3m ~~                                  
##    .Cls_.SGB4037.1                                  0.657    0.254    2.585
##  .Bifidobacterium_dentium.SGB17234.3m ~~                                   
##    .Ent_.SGB7962.1                                  0.129    0.227    0.568
##  .Streptococcus_mitis.SGB8168.3m ~~                                        
##    .Vll_.SGB6936.1                                  0.318    0.171    1.861
##  .overweight ~~                                                            
##    .asthma5y_ep                                    -0.088    0.082   -1.067
##    .Tscore_abnorml                                 -0.138    0.094   -1.469
##    .atopy5y                                        -0.126    0.060   -2.094
##  .asthma5y_ep ~~                                                           
##    .Tscore_abnorml                                  0.126    0.100    1.251
##    .atopy5y                                         0.246    0.072    3.414
##  .Tscore_abnormal ~~                                                       
##    .atopy5y                                         0.097    0.081    1.205
##   P(>|z|)   Std.lv  Std.all
##                            
##     0.021    0.690    0.081
##                            
##     0.000    0.964    0.221
##                            
##     0.000    0.545    0.122
##                            
##     0.075    0.384    0.056
##                            
##     0.009    0.210    0.082
##                            
##     0.226   -0.058   -0.029
##                            
##     0.003   -1.782   -1.489
##                            
##     0.000    0.604    0.156
##                            
##     0.660    0.083    0.012
##                            
##     0.933   -0.003   -0.003
##                            
##     0.134    0.059    0.035
##                            
##     0.002    0.973    0.091
##                            
##     0.400    0.265    0.024
##                            
##     0.094    0.476    0.051
##                            
##     0.000    0.660    2.807
##                            
##     0.000    0.279    0.437
##                            
##     0.000    0.064    0.165
##                            
##     0.000    0.574    0.385
##                            
##     0.000    0.649    0.411
##     0.000    0.050    0.123
##                            
##     0.000    0.438    0.255
##     0.000    0.139    0.118
##                            
##     0.000    2.911    0.480
##                            
##     0.000    0.567    0.222
##                            
##     0.000    4.678    0.793
##                            
##     0.000    1.820    0.404
##                            
##     0.000    0.140    0.068
##     0.000    0.155    0.351
##                            
##     0.392   -0.102   -0.040
##                            
##     0.000    2.373    0.417
##                            
##     0.000    4.393    4.127
##                            
##     0.000    1.390    0.246
##                            
##     0.000    2.979    0.432
##                            
##     0.000    1.821    0.388
##                            
##     0.010    0.047    0.037
##     0.500   -0.013   -0.015
##                            
##     0.000    2.859    3.055
##                            
##     0.000    3.722    0.342
##                            
##     0.000    0.654    0.204
##                            
##     0.000    5.888    0.396
##                            
##     0.000    1.564    0.252
##                            
##     0.000    0.327    0.330
##                            
##     0.000   -0.161   -0.121
##                            
##     0.000    4.961    0.435
##                            
##     0.000    0.244    0.103
##                            
##     0.000    1.210    0.312
##                            
##     0.000    1.498    0.292
##                            
##     0.000    0.736    0.283
##                            
##     0.000    6.153    0.377
##                            
##     0.000    0.871    0.184
##                            
##     0.000    0.886    0.175
##                            
##     0.000   -3.831   -0.335
##                            
##     0.000    0.913    0.555
##                            
##     0.000    1.193    0.268
##                            
##     0.000    5.945    0.448
##                            
##     0.000    0.829    0.174
##                            
##     0.000    2.043    0.227
##                            
##     0.000    1.399    0.206
##                            
##     0.000    1.667    0.283
##     0.000    4.060    6.625
##                            
##     0.000    1.522    0.204
##                            
##     0.000    0.356    0.138
##                            
##     0.000    2.090    0.260
##                            
##     0.000    0.597    0.107
##                            
##     0.000    0.536    0.152
##                            
##     0.000    0.106    0.111
##                            
##     0.201    0.082    0.034
##                            
##     0.000    2.386    0.261
##                            
##     0.000    1.840    0.201
##                            
##     0.000    2.089    0.209
##                            
##     0.000   -4.017   -0.368
##                            
##     0.000    0.431    0.263
##                            
##     0.000    2.234    0.259
##                            
##     0.000    0.075    0.056
##                            
##     0.000   -2.130   -0.197
##                            
##     0.000    2.907    0.278
##                            
##     0.000    2.264    0.221
##                            
##     0.000    1.004    0.251
##     0.000    0.333    0.146
##                            
##     0.000    1.571    0.220
##                            
##     0.000    1.066    0.187
##                            
##     0.000    1.660    0.259
##                            
##     0.000   -1.934   -1.893
##                            
##     0.000    0.403    0.155
##                            
##     0.000    1.588    0.158
##                            
##     0.000    2.515    0.242
##     0.000    2.213    0.184
##                            
##     0.000    0.289    0.120
##                            
##     0.000    1.643    0.178
##                            
##     0.000    2.795    0.222
##                            
##     0.000    2.602    0.218
##                            
##     0.000    0.474    0.307
##                            
##     0.000    1.849    0.202
##                            
##     0.000    0.265    0.109
##                            
##     0.000    1.390    0.172
##                            
##     0.000   -0.223   -0.361
##                            
##     0.000    0.112    0.221
##                            
##     0.000    0.863    0.110
##                            
##     0.000    1.313    0.165
##                            
##     0.000    0.588    0.153
##                            
##     0.000    0.984    0.138
##                            
##     0.000    1.372    0.180
##                            
##     0.000    0.396    0.119
##                            
##     0.000    1.322    0.170
##                            
##     0.000    1.691    0.559
##                            
##     0.000    2.599    0.184
##                            
##     0.001   -0.404   -0.126
##                            
##     0.000    2.355    0.170
##                            
##     0.000    1.106    0.149
##                            
##     0.000    0.558    0.126
##                            
##     0.000    1.883    0.173
##                            
##     0.000    0.620    0.119
##                            
##     0.000    2.063    0.157
##                            
##     0.000    1.793    1.459
##                            
##     0.000    1.757    1.759
##                            
##     0.000    1.577    0.142
##                            
##     0.029   -0.137   -0.068
##                            
##     0.000    2.155    0.160
##                            
##     0.000    2.080    0.188
##                            
##     0.000    2.244    0.162
##                            
##     0.000    0.598    0.122
##                            
##     0.000    1.190    0.147
##                            
##     0.000    2.143    0.184
##                            
##     0.000   -1.392   -0.181
##                            
##     0.000    1.123    0.138
##                            
##     0.000    0.212    0.101
##                            
##     0.000    0.263    0.097
##                            
##     0.000    1.781    0.310
##                            
##     0.000    0.371    0.209
##                            
##     0.000    1.094    0.129
##                            
##     0.000    0.384    0.098
##                            
##     0.000    1.266    0.140
##                            
##     0.000    0.210    0.106
##                            
##     0.000    1.079    1.387
##                            
##     0.000    1.800    0.262
##                            
##     0.000    0.508    0.258
##                            
##     0.000    1.009    0.126
##                            
##     0.000    1.519    0.168
##                            
##     0.001    0.735    0.096
##                            
##     0.000    0.600    0.104
##                            
##     0.000    0.473    0.108
##                            
##     0.000    1.170    0.136
##                            
##     0.000    0.184    0.108
##                            
##     0.000    1.081    0.111
##                            
##     0.000    1.204    0.121
##                            
##     0.000   -0.156   -0.088
##                            
##     0.000    0.823    0.113
##                            
##     0.000    0.882    0.117
##                            
##     0.000    0.563    0.108
##                            
##     0.000    1.229    0.124
##                            
##     0.000    1.045    0.121
##                            
##     0.017    0.470    0.066
##                            
##     0.095   -0.098   -0.039
##                            
##     0.000   -0.239   -0.110
##                            
##     0.332    0.072    0.022
##                            
##     0.000    1.768    0.359
##                            
##     0.070    0.110    0.042
##                            
##     0.000    0.839    0.100
##                            
##     0.000    1.082    0.119
##                            
##     0.000    1.154    0.218
##                            
##     0.000    0.538    0.121
##                            
##     0.000    0.911    0.195
##                            
##     0.000    0.499    0.099
##                            
##     0.000   -0.685   -0.105
##                            
##     0.000   -1.061   -0.123
##                            
##     0.000    1.139    0.108
##                            
##     0.000    0.601    0.106
##                            
##     0.000    1.464    0.116
##                            
##     0.000    2.248    0.142
##                            
##     0.000   -1.661   -0.135
##                            
##     0.370    0.082    0.020
##                            
##     0.005    0.074    0.040
##                            
##     0.855   -0.009   -0.003
##                            
##     0.001    1.220    0.101
##                            
##     0.000    0.796    0.099
##                            
##     0.133    0.098    0.028
##                            
##     0.001    0.535    0.096
##                            
##     0.001    1.362    0.117
##                            
##     0.013    0.423    0.063
##                            
##     0.002    0.119    0.055
##                            
##     0.001    0.397    0.089
##                            
##     0.002    0.133    0.054
##                            
##     0.002    1.498    0.104
##                            
##     0.001    0.169    0.074
##                            
##     0.000    3.102    0.424
##                            
##     0.000    1.537    0.365
##                            
##     0.001   -0.235   -0.175
##     0.000    2.899    5.531
##                            
##     0.000   -0.423   -0.294
##     0.000    6.174   11.050
##                            
##     0.001    0.287    0.111
##                            
##     0.000    0.968    6.440
##                            
##     0.000   -0.191   -0.197
##     0.004    0.153    0.120
##                            
##     0.004   -0.166   -0.105
##                            
##     0.000    1.677    0.209
##     0.086    0.184    0.060
##                            
##     0.000    1.491    1.687
##                            
##     0.003    0.150    0.097
##                            
##     0.000    0.910    0.263
##                            
##     0.000    0.854    0.201
##                            
##     0.000    2.808    7.456
##                            
##     0.058    0.113    0.050
##                            
##     0.119    0.071    0.039
##     0.000    0.664    0.156
##                            
##     0.000    1.175    0.629
##                            
##     0.000    2.478    0.405
##                            
##     0.000   -0.834   -0.386
##                            
##     0.074   -0.081   -0.057
##                            
##     0.000   -0.782   -1.833
##                            
##     0.002    0.444    0.078
##                            
##     0.013    0.202    0.107
##     0.000    1.324    0.296
##                            
##     0.024    0.128    0.051
##                            
##     0.000    2.254    4.046
##                            
##     0.000   -0.707   -0.308
##                            
##     0.000    0.763    0.169
##                            
##     0.000   -2.458   -2.451
##     0.000    1.108    0.181
##     0.000    1.319    0.196
##                            
##     0.000   -1.670   -2.253
##     0.387    0.071    0.037
##     0.000    0.253    0.208
##                            
##     0.000   -3.187   -4.336
##                            
##     0.030    0.813    0.850
##                            
##     0.000   -1.885   -3.124
##                            
##     0.000   -1.124   -4.179
##     0.009    0.067    0.098
##                            
##     0.989    0.001    0.000
##                            
##     0.812    0.014    0.005
##                            
##     0.000    1.110    1.902
##     0.138   -0.096   -0.064
##                            
##     0.788   -0.012   -0.006
##                            
##     0.007   -0.887   -1.273
##                            
##     0.043    0.109    0.049
##                            
##     0.000    1.527    1.978
##                            
##     0.001    0.996    0.137
##                            
##     0.001    0.619    0.115
##                            
##     0.003    0.112    0.060
##                            
##     0.003    0.743    0.088
##                            
##     0.001   -0.186   -0.073
##                            
##     0.001   -1.603   -1.247
##                            
##     0.109    0.040    0.050
##     0.000   -0.756   -2.442
##                            
##     0.850    0.007    0.007
##     0.172   -0.197   -0.494
##                            
##     0.002   -0.242   -0.097
##                            
##     0.002    0.655    0.091
##                            
##     0.000    0.739    0.323
##                            
##     0.003    0.818    0.137
##                            
##     0.069   -0.100   -0.062
##                            
##     0.001   -0.586   -0.161
##                            
##     0.000    0.174    0.093
##                            
##     0.009    0.714    1.126
##                            
##     0.002   -0.694   -0.137
##                            
##     0.004    0.514    0.118
##                            
##     0.000    0.639    0.174
##                            
##     0.005    0.969    0.088
##                            
##     0.003    0.471    0.078
##                            
##     0.003    0.515    0.079
##                            
##     0.063    0.150    0.062
##                            
##     0.004    1.183    0.091
##                            
##     0.003    1.065    0.094
##                            
##     0.009    0.412    0.075
##                            
##     0.747   -0.024   -0.010
##                            
##     0.000   -1.944   -0.571
##                            
##     0.003   -0.249   -0.066
##                            
##     0.003    1.214    0.092
##                            
##     0.002    0.212    0.113
##                            
##     0.004    1.199    0.091
##                            
##     0.008    0.103    0.048
##                            
##     0.000    0.477    0.256
##                            
##     0.000    0.094    0.134
##                            
##     0.000    0.357    0.217
##                            
##     0.000   -0.282   -0.327
##                            
##     0.000    0.392    0.324
##                            
##     0.029    0.044    0.066
##                            
##     0.002    0.130    0.092
##                            
##     0.000    0.149    0.130
##                            
##     0.005    1.049    0.088
##                            
##     0.006    1.081    0.087
##                            
##     0.005    1.100    0.086
##                            
##     0.005   -0.144   -0.057
##     0.005    1.067    0.089
##                            
##     0.033    0.082    0.104
##     0.000   -1.475   -4.821
##                            
##     0.823    0.014    0.012
##                            
##     0.854    0.012    0.005
##                            
##     0.005    0.663    0.084
##                            
##     0.006   -0.932   -0.085
##                            
##     0.008    0.216    0.069
##                            
##     0.008    0.935    0.083
##                            
##     0.010    0.127    0.045
##                            
##     0.000    0.355    0.321
##                            
##     0.000    0.388    0.215
##                            
##     0.003    0.281    0.073
##                            
##     0.866   -0.008   -0.004
##                            
##     0.006    0.579    0.078
##                            
##     0.006   -0.525   -0.119
##                            
##     0.007    0.151    0.048
##                            
##     0.003    0.836    0.102
##                            
##     0.008   -0.869   -0.101
##                            
##     0.002    0.186    0.051
##                            
##     0.013    0.537    0.071
##                            
##     0.000   -1.733   -0.753
##                            
##     0.008   -0.180   -0.064
##                            
##     0.010   -1.091   -0.091
##                            
##     0.008   -1.528   -0.090
##                            
##     0.104    0.138    0.044
##                            
##     0.003    0.155    0.077
##                            
##     0.000   -0.965   -0.275
##                            
##     0.000    1.205    0.245
##                            
##     0.025    0.424    0.084
##                            
##     0.024    0.148    0.049
##                            
##     0.018    0.059    0.056
##                            
##     0.007    0.458    0.074
##                            
##     0.025   -0.314   -0.077
##                            
##     0.011    0.652    0.073
##                            
##     0.011    0.734    0.074
##                            
##     0.007    0.905    0.081
##                            
##     0.009    1.408    0.086
##                            
##     0.005   -1.422   -0.093
##                            
##     0.014    0.297    0.057
##                            
##     0.005   -1.088   -1.120
##                            
##     0.017   -0.103   -0.077
##                            
##     0.009    0.832    0.070
##                            
##     0.106    0.092    0.053
##                            
##     0.003    0.139    0.096
##                            
##     0.364    0.201    0.033
##                            
##     0.011   -0.906   -0.084
##                            
##     0.010    0.568    0.073
##                            
##     0.003    0.668    0.084
##                            
##     0.011    0.157    0.055
##                            
##     0.010    1.029    0.084
##                            
##     0.009    1.013    0.086
##                            
##     0.008    0.625    0.074
##                            
##     0.016   -0.532   -0.094
##                            
##     0.203    0.073    0.032
##                            
##     0.015    0.411    0.067
##                            
##     0.016    0.755    0.069
##                            
##     0.011    0.987    0.081
##                            
##     0.012    0.789    0.080
##                            
##     0.001   -0.458   -0.144
##     0.022    0.211    0.086
##                            
##     0.012    0.728    0.072
##                            
##     0.013    0.720    0.071
##                            
##     0.011    0.711    0.076
##                            
##     0.000   -0.796   -0.213
##                            
##     0.007   -0.786   -0.102
##                            
##     0.008   -0.439   -0.103
##                            
##     0.014   -0.979   -0.092
##                            
##     0.005    0.715    0.091
##                            
##     0.000    0.233    0.112
##                            
##     0.021   -0.208   -0.061
##                            
##     0.039   -0.294   -0.052
##                            
##     0.056    0.538    0.060
##                            
##     0.015   -0.426   -0.066
##                            
##     0.011    0.651    0.069
##                            
##     0.019   -0.758   -0.080
##                            
##     0.009   -0.657   -0.081
##                            
##     0.028   -0.749   -0.109
##                            
##     0.018   -0.556   -0.102
##                            
##     0.003    0.154    0.055
##                            
##     0.084    0.514    0.542
##                            
##     0.010    0.110    0.068
##                            
##     0.015    0.668    0.075
##                            
##     0.016    0.425    0.065
##                            
##     0.013    0.594    0.074
##                            
##     0.010   -0.674   -0.078
##                            
##     0.006    0.857    0.086
##                            
##     0.014    0.817    0.075
##                            
##     0.016   -0.715   -0.084
##                            
##     0.000   -1.973   -4.937
##     0.068    0.133    0.130
##                            
##     0.315   -0.191   -0.035
##                            
##     0.008    0.059    0.056
##                            
##     0.017    0.570    0.066
##                            
##     0.014    0.505    0.101
##                            
##     0.000   -1.732   -0.541
##                            
##     0.000    1.542    0.418
##                            
##     0.000    0.558    0.214
##                            
##     0.000    2.364    0.527
##                            
##     0.000    1.339    0.296
##                            
##     0.000   -1.964   -0.525
##     0.002   -1.195   -0.170
##     0.000    0.964    0.226
##     0.006   -0.767   -0.142
##                            
##     0.000    0.521    0.276
##                            
##     0.000   -0.554   -0.603
##                            
##     0.001   -0.229   -0.092
##                            
##     0.002   -0.772   -0.216
##                            
##     0.004   -1.179   -0.100
##                            
##     0.008    0.691    0.077
##                            
##     0.006    0.505    0.102
##                            
##     0.012    0.635    0.065
##                            
##     0.008    1.036    0.081
##                            
##     0.011    0.779    0.075
##                            
##     0.019   -0.785   -0.083
##                            
##     0.015    0.456    0.064
##                            
##     0.018   -0.833   -0.082
##                            
##     0.012    0.755    0.077
##                            
##     0.019    1.037    0.079
##                            
##     0.020    0.677    0.070
##                            
##     0.043    0.181    0.050
##                            
##     0.014    1.050    0.077
##                            
##     0.020    0.823    0.069
##                            
##     0.012   -0.891   -0.081
##                            
##     0.007    0.249    0.064
##                            
##     0.015    0.890    0.076
##                            
##     0.014   -0.820   -0.079
##                            
##     0.025    0.538    0.065
##                            
##     0.023   -0.668   -0.077
##                            
##     0.023   -0.890   -0.072
##                            
##     0.026    0.407    0.057
##                            
##     0.024   -0.600   -0.080
##                            
##     0.016    0.869    0.073
##                            
##     0.179   -0.103   -0.035
##                            
##     0.017    1.019    0.070
##                            
##     0.090   -0.468   -0.062
##                            
##     0.030   -0.649   -0.068
##                            
##     0.024   -0.859   -0.066
##                            
##     0.010   -1.194   -0.085
##                            
##     0.024    0.687    0.067
##                            
##     0.020    0.748    0.073
##                            
##     0.458   -0.307   -0.347
##                            
##     0.000   -0.184   -0.201
##                            
##     0.033    0.094    0.065
##                            
##     0.001    0.187    0.117
##                            
##     0.016    0.058    0.031
##                            
##     0.149    0.300    0.048
##                            
##     0.137    0.096    0.028
##                            
##     0.024   -0.883   -0.072
##                            
##     0.022    0.636    0.069
##                            
##     0.026   -0.488   -0.085
##                            
##     0.024   -1.049   -0.091
##                            
##     0.032   -0.129   -0.039
##                            
##     0.021    0.404    0.069
##                            
##     0.028   -0.916   -0.069
##                            
##     0.029    0.739    0.062
##                            
##     0.029    0.254    0.056
##                            
##     0.014    0.747    0.076
##                            
##     0.003    0.434    0.093
##                            
##     0.000    1.378    0.564
##     0.000    0.575    0.236
##     0.000    0.610    0.371
##     0.000    0.679    0.254
##                            
##     0.000    0.450    0.256
##                            
##     0.000   -0.575   -0.234
##                            
##     0.057    0.110    0.042
##                            
##     0.018    0.244    0.057
##                            
##     0.014    0.770    0.078
##                            
##     0.000   -0.224   -0.223
##                            
##     0.143   -0.453   -0.078
##     0.038   -0.470   -0.121
##     0.005   -0.771   -0.164
##                            
##     0.015   -0.118   -0.093
##                            
##     0.066   -0.328   -0.070
##                            
##     0.005    0.768    0.078
##                            
##     0.012   -0.802   -0.085
##                            
##     0.314   -0.084   -0.025
##                            
##     0.022    0.251    0.059
##                            
##     0.018    0.815    0.070
##                            
##     0.035    0.442    0.058
##                            
##     0.019   -0.900   -0.087
##                            
##     0.005    1.328    0.095
##                            
##     0.028    0.762    0.065
##                            
##     0.128   -0.383   -0.058
##                            
##     0.031    0.393    0.058
##                            
##     0.051   -0.668   -0.061
##                            
##     0.033   -0.664   -0.073
##                            
##     0.029   -0.622   -0.073
##                            
##     0.046   -0.619   -0.126
##                            
##     0.042   -0.430   -0.058
##                            
##     0.038    0.372    0.057
##                            
##     0.018   -0.692   -0.081
##                            
##     0.003    0.983    0.166
##     0.065    0.376    0.067
##     0.013   -0.186   -0.057
##     0.009    0.561    0.086
##                            
##     0.102    0.194    0.068
##                            
##     0.002    0.557    0.138
##                            
##     0.065    0.377    0.064
##                            
##     0.000    0.471    0.230
##                            
##     0.121   -0.372   -0.058
##                            
##     0.570    0.055    0.021
##                            
##     0.138   -0.258   -0.050
##                            
##     0.115    0.476    0.088
##                            
##     0.013    0.717    0.075
##                            
##     0.191    0.146    0.035
##                            
##     0.000    0.195    0.297
##     0.000   -0.499   -0.189
##                            
##     0.015   -0.129   -0.068
##                            
##     0.011    0.697    0.075
##                            
##     0.066    0.862    0.056
##                            
##     0.190   -0.467   -0.066
##                            
##     0.034    0.581    0.064
##                            
##     0.053    0.367    0.055
##                            
##     0.036   -0.405   -0.065
##     0.040   -0.455   -0.091
##                            
##     0.042   -1.020   -0.068
##                            
##     0.038   -0.764   -0.064
##                            
##     0.069   -0.239   -0.042
##                            
##     0.039   -0.960   -0.071
##                            
##     0.036    0.745    0.058
##                            
##     0.043   -0.692   -0.065
##                            
##     0.036   -0.153   -0.059
##                            
##     0.161   -0.097   -0.033
##                            
##     0.021   -0.929   -0.069
##                            
##     0.043    0.335    0.050
##                            
##     0.011   -0.184   -0.062
##                            
##     0.042   -0.444   -0.062
##                            
##     0.024    0.277    0.057
##                            
##     0.078    0.116    0.042
##                            
##     0.041   -0.694   -0.070
##                            
##     0.039   -0.877   -0.064
##                            
##     0.599   -0.069   -0.018
##                            
##     0.103    0.465    0.071
##                            
##     0.030    0.173    0.048
##                            
##     0.046    0.389    0.065
##                            
##     0.112    0.289    0.050
##                            
##     0.042   -0.726   -0.064
##                            
##     0.029   -0.728   -0.070
##                            
##     0.044    0.435    0.059
##                            
##     0.049    0.522    0.057
##                            
##     0.041   -0.652   -0.064
##     0.039    0.672    0.060
##                            
##     0.105    0.175    0.036
##                            
##     0.301   -0.240   -0.035
##                            
##     0.036    0.216    0.053
##                            
##     0.057   -0.355   -0.055
##                            
##     0.035    0.293    0.072
##     0.000   -0.264   -0.225
##                            
##     0.050   -0.720   -0.064
##                            
##     0.046    0.758    0.060
##                            
##     0.044    0.427    0.052
##                            
##     0.041    0.679    0.060
##                            
##     0.044    0.378    0.051
##                            
##     0.196   -0.253   -0.048
##                            
##     0.046   -0.937   -0.061
##                            
##     0.048   -0.786   -0.058
##                            
##     0.047   -0.679   -0.065
##                            
##     0.060    0.332    0.051
##                            
##     0.039    0.663    0.062
##                            
##     0.023   -0.712   -0.083
##                            
##     0.000    1.070    0.373
##     0.000    0.403    0.230
##     0.000    0.864    0.348
##                            
##     0.000    0.841    0.275
##                            
##     0.000    1.601    0.388
##                            
##     0.000    0.260    0.158
##     0.000    0.495    0.393
##                            
##     0.000    4.127    0.489
##                            
##     0.000    3.459    0.338
##                            
##     0.000    0.610    0.248
##                            
##     0.000    1.327    0.194
##                            
##     0.000    2.077    0.279
##                            
##     0.000    0.271    0.126
##                            
##     0.000    1.700    0.182
##                            
##     0.000    1.636    0.204
##                            
##     0.000    0.898    0.179
##                            
##     0.000    2.958    0.207
##                            
##     0.000    1.565    0.173
##                            
##     0.000    0.434    0.145
##                            
##     0.000    0.660    0.181
##                            
##     0.000    1.652    1.880
##                            
##     0.570   -0.021   -0.015
##                            
##     0.000    1.890    1.831
##                            
##     0.000    0.141    0.280
##                            
##     0.000   -0.123   -0.137
##                            
##     0.001    0.071    0.049
##                            
##     0.000   -0.198   -0.085
##                            
##     0.000    1.052    0.138
##                            
##     0.000    0.088    0.074
##                            
##     0.000    1.949    1.606
##                            
##     0.001   -0.388   -0.148
##                            
##     0.000    0.309    0.095
##                            
##     0.011   -0.268   -0.080
##                            
##     0.000    0.157    0.079
##                            
##     0.003    0.489    0.122
##                            
##     0.000    0.361    0.141
##                            
##     0.000    0.815    0.122
##                            
##     0.000    1.443    0.140
##                            
##     0.000    1.285    0.128
##                            
##     0.000    0.716    0.109
##                            
##     0.000    1.464    0.160
##                            
##     0.000    0.875    0.127
##                            
##     0.000   -1.373   -0.116
##                            
##     0.003   -0.121   -0.085
##                            
##     0.000   -1.393   -0.129
##                            
##     0.000    0.480    0.089
##                            
##     0.000    1.593    0.166
##                            
##     0.543   -0.022   -0.010
##                            
##     0.001   -0.089   -0.086
##                            
##     0.013   -0.434   -0.137
##                            
##     0.005   -0.287   -0.097
##                            
##     0.000    0.994    0.104
##                            
##     0.001    0.656    0.092
##                            
##     0.001    1.031    0.107
##                            
##     0.001   -0.452   -0.124
##                            
##     0.001    0.552    0.092
##                            
##     0.001    0.738    0.099
##                            
##     0.001    0.455    0.087
##                            
##     0.001    0.130    0.049
##                            
##     0.001   -1.359   -0.111
##                            
##     0.001    0.642    0.094
##                            
##     0.001    1.155    0.106
##                            
##     0.001    0.408    0.085
##                            
##     0.001   -1.413   -0.108
##                            
##     0.001   -1.951   -0.126
##                            
##     0.001    0.842    0.105
##                            
##     0.001   -1.722   -0.115
##                            
##     0.001    0.892    0.096
##                            
##     0.001    1.330    0.107
##                            
##     0.001    0.412    0.084
##                            
##     0.001    0.838    0.099
##                            
##     0.001    1.204    0.103
##                            
##     0.001    1.917    0.120
##                            
##     0.001    0.771    0.123
##                            
##     0.000   -1.527   -1.355
##                            
##     0.001    0.697    0.094
##                            
##     0.001    1.207    0.105
##                            
##     0.001    1.503    0.111
##                            
##     0.001    0.155    0.098
##                            
##     0.002   -1.294   -0.100
##                            
##     0.002   -1.334   -0.106
##                            
##     0.002   -1.061   -0.108
##                            
##     0.002    1.059    0.099
##                            
##     0.002    0.165    0.060
##                            
##     0.014    0.296    0.083
##                            
##     0.001   -0.894   -0.113
##                            
##     0.002   -0.240   -0.086
##                            
##     0.002    1.146    0.087
##                            
##     0.000   -0.949   -0.136
##                            
##     0.003    0.398    0.084
##                            
##     0.003    0.210    0.055
##                            
##     0.006    0.127    0.065
##                            
##     0.035   -0.192   -0.055
##                            
##     0.075   -0.211   -0.053
##                            
##     0.130   -0.231   -0.041
##                            
##     0.063   -0.086   -0.042
##                            
##     0.041   -0.369   -0.078
##     0.048   -0.387   -0.098
##                            
##     0.031    0.680    0.099
##                            
##     0.031   -0.827   -0.115
##                            
##     0.049    0.282    0.078
##     0.045    0.238    0.065
##                            
##     0.021    0.590    0.073
##                            
##     0.028    0.113    0.059
##                            
##     0.000    0.894    0.135
##     0.028    0.829    0.071
##                            
##     0.023    0.117    0.048
##                            
##     0.033    0.761    0.065
##                            
##     0.034   -0.509   -0.068
##                            
##     0.047   -0.622   -0.069
##                            
##     0.023    0.975    0.858
##                            
##     0.041   -0.636   -0.073
##                            
##     0.045   -0.508   -0.060
##                            
##     0.050   -0.514   -0.079
##                            
##     0.041    0.505    0.060
##                            
##     0.048   -0.532   -0.065
##                            
##     0.054    0.340    0.054
##                            
##     0.041    0.111    0.038
##                            
##     0.010    0.657    0.076
##                            
##     0.570    0.129    0.022
##                            
##     0.063    0.318    0.052
##                            
##     0.286   -0.088   -0.090
##     0.142   -0.138   -0.542
##     0.036   -0.126   -0.127
##                            
##     0.211    0.126    0.494
##     0.001    0.246    0.249
##                            
##     0.228    0.097    0.378
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Bfdbctrm_l...3   -1.083    1.296   -0.835    0.404   -1.083   -0.277
##    .Bct_.SGB1877.3    0.111    0.687    0.162    0.872    0.111    0.053
##    .Bct_.SGB1855.3   -0.867    1.277   -0.679    0.497   -0.867   -0.245
##    .Bct_.SGB1861.3    0.219    0.830    0.264    0.792    0.219    0.091
##    .Bf_.SGB17278.3   -1.083    0.862   -1.256    0.209   -1.083   -0.426
##    .Bf_.SGB17234.3    0.889    1.036    0.858    0.391    0.889    0.274
##    .Cls_.SGB4037.3   -0.497    0.931   -0.534    0.593   -0.497   -0.182
##    .C__C5_48.SGB47   -1.130    0.488   -2.314    0.021   -1.130   -0.753
##    .Eg_.SGB14809.3   -0.385    1.130   -0.340    0.733   -0.385   -0.112
##    .Ent_.SGB4760.3   -0.857    0.541   -1.584    0.113   -0.857   -0.560
##    .Ent_.SGB7931.3   -1.225    0.735   -1.666    0.096   -1.225   -0.613
##    .Ent_.SGB7962.3    3.663    1.129    3.246    0.001    3.663    0.985
##    .Ebc_.SGB4933.3    0.355    0.903    0.393    0.695    0.355    0.366
##    .Fc_.SGB15316.3   -0.395    0.444   -0.889    0.374   -0.395   -0.374
##    .Hng_.SGB4742.3   -0.740    0.882   -0.839    0.402   -0.740   -0.347
##    .Mdt_.SGB4563.3    0.063    0.669    0.095    0.925    0.063    0.044
##    .Mgs_.SGB5868.3   -0.290    0.472   -0.613    0.540   -0.290   -0.254
##    .Phc_.SGB1815.3    0.655    0.933    0.702    0.483    0.655    0.238
##    .Phc_.SGB1814.3    0.425    0.984    0.432    0.666    0.425    0.144
##    .Rt_.SGB16985.3    1.674    0.746    2.243    0.025    1.674    0.701
##    .Rmn_.SGB4584.3   -0.340    1.400   -0.243    0.808   -0.340   -0.083
##    .Rmn_.SGB4608.3   -0.266    0.500   -0.532    0.595   -0.266   -0.201
##    .Rt_.SGB15271.3   -0.320    0.702   -0.456    0.649   -0.320   -0.164
##    .Str_.SGB8065.3    2.489    1.104    2.254    0.024    2.489    0.704
##    .Str_.SGB8168.3    2.164    0.650    3.326    0.001    2.164    1.023
##    .Str_.SGB8084.3    1.068    0.647    1.652    0.098    1.068    0.497
##    .Str_.SGB8005.3    3.300    1.075    3.069    0.002    3.300    0.978
##    .St_.SGB8007_.3    3.552    1.047    3.391    0.001    3.552    1.099
##    .Str_.SGB8002.3   -0.296    0.750   -0.395    0.693   -0.296   -0.125
##    .Vll_.SGB6936.3    0.549    0.683    0.804    0.421    0.549    0.259
##    .Bfdbctrm_l...1    5.493    1.368    4.017    0.000    5.493    1.438
##    .Bct_.SGB1877.1    0.667    0.867    0.769    0.442    0.667    0.246
##    .Bct_.SGB1855.1   -1.415    1.382   -1.024    0.306   -1.415   -0.377
##    .Bct_.SGB1861.1   -0.559    0.953   -0.587    0.557   -0.559   -0.195
##    .Bf_.SGB17278.1    4.940    1.238    3.991    0.000    4.940    1.231
##    .Bf_.SGB17234.1    6.172    1.190    5.189    0.000    6.172    1.966
##    .Cls_.SGB4037.1    4.835    1.124    4.302    0.000    4.835    1.374
##    .C__C5_48.SGB47    0.654    1.198    0.546    0.585    0.654    0.198
##    .Eg_.SGB14809.1    3.245    1.019    3.186    0.001    3.245    1.048
##    .Ent_.SGB4760.1    0.031    0.760    0.041    0.967    0.031    0.014
##    .Ent_.SGB7931.1    2.619    0.936    2.798    0.005    2.619    1.017
##    .Ent_.SGB7962.1    0.842    0.685    1.228    0.219    0.842    0.414
##    .Ebc_.SGB4933.1   -4.818    1.427   -3.376    0.001   -4.818   -1.293
##    .Fc_.SGB15316.1   -4.406    1.942   -2.269    0.023   -4.406   -1.036
##    .Hng_.SGB4742.1    0.652    1.000    0.652    0.515    0.652    0.224
##    .Mdt_.SGB4563.1   -0.228    1.167   -0.196    0.845   -0.228   -0.068
##    .Mgs_.SGB5868.1    3.827    0.900    4.250    0.000    3.827    1.485
##    .Phc_.SGB1815.1   -0.090    1.122   -0.080    0.936   -0.090   -0.028
##    .Phc_.SGB1814.1    1.424    1.239    1.149    0.250    1.424    0.369
##    .Rt_.SGB16985.1    0.218    0.438    0.498    0.619    0.218    0.265
##    .Rmn_.SGB4584.1    7.344    1.062    6.917    0.000    7.344    2.360
##    .Rmn_.SGB4608.1   -4.064    1.106   -3.674    0.000   -4.064   -1.377
##    .Rt_.SGB15271.1   -2.251    1.159   -1.942    0.052   -2.251   -0.761
##    .Str_.SGB8065.1    1.609    0.716    2.248    0.025    1.609    0.839
##    .Str_.SGB8168.1    0.228    0.385    0.593    0.553    0.228    0.389
##    .Str_.SGB8084.1    0.158    0.393    0.402    0.687    0.158    0.196
##    .Str_.SGB8005.1    2.629    1.010    2.602    0.009    2.629    0.828
##    .St_.SGB8007_.1   -4.072    1.245   -3.270    0.001   -4.072   -1.193
##    .Str_.SGB8002.1    3.961    1.247    3.175    0.001    3.961    0.974
##    .Vll_.SGB6936.1    4.191    0.965    4.342    0.000    4.191    1.428
## 
## Thresholds:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     overweight|t1    -0.070    0.518   -0.136    0.892   -0.070   -0.069
##     asthma5y_ep|t1    1.551    0.617    2.514    0.012    1.551    1.524
##     Tscor_bnrml|t1    2.782    0.627    4.439    0.000    2.782    2.671
##     atopy5y|t1        0.578    0.489    1.182    0.237    0.578    0.551
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .Bfdbctrm_l...3   15.285    1.293   11.819    0.000   15.285    0.997
##    .Bct_.SGB1877.3    4.404    0.329   13.401    0.000    4.404    0.999
##    .Bct_.SGB1855.3   12.490    1.455    8.582    0.000   12.490    1.000
##    .Bct_.SGB1861.3    5.792    0.497   11.646    0.000    5.792    1.000
##    .Bf_.SGB17278.3    6.004    0.322   18.635    0.000    6.004    0.929
##    .Bf_.SGB17234.3   10.314    0.771   13.375    0.000   10.314    0.979
##    .Cls_.SGB4037.3    5.906    0.416   14.193    0.000    5.906    0.789
##    .C__C5_48.SGB47    1.746    0.083   21.096    0.000    1.746    0.777
##    .Eg_.SGB14809.3   11.000    1.237    8.895    0.000   11.000    0.925
##    .Ent_.SGB4760.3    1.551    0.137   11.343    0.000    1.551    0.663
##    .Ent_.SGB7931.3    3.003    0.230   13.046    0.000    3.003    0.753
##    .Ent_.SGB7962.3   13.827    1.276   10.837    0.000   13.827    1.000
##    .Ebc_.SGB4933.3    0.791    0.044   17.814    0.000    0.791    0.843
##    .Fc_.SGB15316.3    1.047    0.036   29.132    0.000    1.047    0.937
##    .Hng_.SGB4742.3    3.979    0.233   17.093    0.000    3.979    0.877
##    .Mdt_.SGB4563.3    1.987    0.097   20.433    0.000    1.987    0.969
##    .Mgs_.SGB5868.3    1.023    0.046   22.357    0.000    1.023    0.787
##    .Phc_.SGB1815.3    3.413    0.550    6.200    0.000    3.413    0.450
##    .Phc_.SGB1814.3    8.742    0.821   10.649    0.000    8.742    1.000
##    .Rt_.SGB16985.3    5.695    0.522   10.917    0.000    5.695    0.999
##    .Rmn_.SGB4584.3   15.668    1.599    9.801    0.000   15.668    0.925
##    .Rmn_.SGB4608.3    1.745    0.083   21.060    0.000    1.745    0.993
##    .Rt_.SGB15271.3    3.725    0.299   12.456    0.000    3.725    0.980
##    .Str_.SGB8065.3   12.515    1.399    8.945    0.000   12.515    1.000
##    .Str_.SGB8168.3    4.402    0.351   12.554    0.000    4.402    0.983
##    .Str_.SGB8084.3    4.616    0.382   12.093    0.000    4.616    0.999
##    .Str_.SGB8005.3   11.391    1.213    9.394    0.000   11.391    1.000
##    .St_.SGB8007_.3   10.431    0.963   10.837    0.000   10.431    1.000
##    .Str_.SGB8002.3    5.314    0.344   15.432    0.000    5.314    0.952
##    .Vll_.SGB6936.3    4.479    0.273   16.400    0.000    4.479    1.000
##    .Bfdbctrm_l...1   14.453    1.212   11.924    0.000   14.453    0.991
##    .Bct_.SGB1877.1    7.338    0.778    9.433    0.000    7.338    1.000
##    .Bct_.SGB1855.1   14.097    1.724    8.177    0.000   14.097    1.000
##    .Bct_.SGB1861.1    8.208    0.872    9.409    0.000    8.208    0.997
##    .Bf_.SGB17278.1   16.106    1.801    8.945    0.000   16.106    1.000
##    .Bf_.SGB17234.1    9.832    0.860   11.436    0.000    9.832    0.998
##    .Cls_.SGB4037.1   12.384    1.147   10.799    0.000   12.384    1.000
##    .C__C5_48.SGB47   10.912    1.257    8.681    0.000   10.912    1.000
##    .Eg_.SGB14809.1    9.579    0.746   12.840    0.000    9.579    1.000
##    .Ent_.SGB4760.1    4.105    0.358   11.455    0.000    4.105    0.822
##    .Ent_.SGB7931.1    6.618    0.598   11.072    0.000    6.618    0.998
##    .Ent_.SGB7962.1    3.391    0.275   12.354    0.000    3.391    0.820
##    .Ebc_.SGB4933.1   13.886    1.682    8.254    0.000   13.886    0.999
##    .Fc_.SGB15316.1   18.072    2.869    6.298    0.000   18.072    0.999
##    .Hng_.SGB4742.1    8.439    0.835   10.112    0.000    8.439    0.994
##    .Mdt_.SGB4563.1   11.400    1.198    9.514    0.000   11.400    1.000
##    .Mgs_.SGB5868.1    6.511    0.625   10.412    0.000    6.511    0.980
##    .Phc_.SGB1815.1   10.184    1.170    8.704    0.000   10.184    1.000
##    .Phc_.SGB1814.1   14.872    1.871    7.949    0.000   14.872    0.999
##    .Rt_.SGB16985.1    0.677    0.041   16.696    0.000    0.677    1.000
##    .Rmn_.SGB4584.1   -0.091    1.067   -0.086    0.932   -0.091   -0.009
##    .Rmn_.SGB4608.1    8.564    0.802   10.672    0.000    8.564    0.983
##    .Rt_.SGB15271.1    8.711    0.997    8.742    0.000    8.711    0.996
##    .Str_.SGB8065.1    3.676    0.265   13.882    0.000    3.676    1.000
##    .Str_.SGB8168.1    0.247    0.030    8.129    0.000    0.247    0.717
##    .Str_.SGB8084.1    0.604    0.030   19.892    0.000    0.604    0.931
##    .Str_.SGB8005.1   10.009    1.007    9.936    0.000   10.009    0.994
##    .St_.SGB8007_.1   11.649    1.117   10.426    0.000   11.649    1.000
##    .Str_.SGB8002.1   16.507    1.733    9.526    0.000   16.507    0.999
##    .Vll_.SGB6936.1    8.540    0.750   11.391    0.000    8.540    0.991
##    .overweight        0.981                               0.981    0.946
##    .asthma5y_ep       0.975                               0.975    0.941
##    .Tscore_abnorml    0.066                               0.066    0.061
##    .atopy5y           0.999                               0.999    0.906
##    .microbiome        0.041    0.026    1.578    0.114    0.959    0.959
## 
## Defined Parameters:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##     ind_overweight   -0.015    0.004   -3.354    0.001   -0.015   -0.010
##     total_overwght   -0.078    0.070   -1.113    0.266   -0.078   -0.054
##     ind_asthma5y_p   -0.017    0.005   -3.127    0.002   -0.017   -0.012
##     total_sthm5y_p   -0.133    0.090   -1.489    0.137   -0.133   -0.092
##     ind_Tscr_bnrml   -0.103    0.027   -3.833    0.000   -0.103   -0.070
##     ttl_Tscr_bnrml   -0.305    0.108   -2.817    0.005   -0.305   -0.206
##     ind_atopy5y       0.003    0.002    1.309    0.190    0.003    0.002
##     total_atopy5y    -0.058    0.067   -0.857    0.391   -0.058   -0.039

##Get the features associated with metacyc pathways

SES.maaslin.combine <- unique(SES.maaslin)
######################################################################
#Combine the models with and without interaction. If slope not significant (p-value > 0.05), use the models without interaction.  
qval.ct <- 0.1
exclude.val <- c("toronto","vancouver","winnipeg","square_age","exact_age","ProcessingPeriod","1")
check.var.use <- unique(SES.maaslin.combine$check.var)

SES.masslin.all <- NULL
adj.vars.basics <- list(c("ProcessingPeriod", "exact_age","site"))
for(BFsub.use in c("All","AnyBF")){
  for(adj.vars.basic.use in unique(SES.maaslin.combine$adjbasic)){
    for(norm.use in c("MCLR")){
      SES.masslin.new <- subset(SES.maaslin.combine,   BFsub==BFsub.use & Race.Adj=="none" & 
                                  Normalization==norm.use & adjbasic==adj.vars.basic.use &
                                  Visit=="longitudinal" & Data=="META" & Prevalence_cutoff==0.1)
      for(check.var.i in check.var.use){
        ses.sp.int <- subset(SES.masslin.new, check.var%in%check.var.i & value%in%c("time_interaction") & !value%in%exclude.val & Model=="Interact" )
        ses.sp.main <-  subset(SES.masslin.new, check.var%in%check.var.i & !value%in%exclude.val & Model=="Nointeract" )
        ff.no.int <- subset(ses.sp.int, pval>=0.05)
        ff.sig.int <-  subset(ses.sp.int, pval<0.05)
        
        ses.sp.int.all <-  subset(SES.masslin.new, check.var%in%check.var.i & value%in%c("time_interaction",check.var.i,"exact_age") &
                                    Model=="Interact" )
        ses.sp.main.all <- subset(SES.masslin.new, check.var%in%check.var.i & value%in%c(check.var.i,"exact_age")  & Model=="Nointeract")
        ses.new.i <- rbind(ses.sp.int.all,
                           ses.sp.main.all)
        SES.masslin.all <- rbind(SES.masslin.all, ses.new.i)
      }
    }
  }
}
SES.masslin.all$feature_update <- strsplit2(SES.masslin.all$feature,"__")[,1]
dup.name <- strsplit2(unique(SES.masslin.all$feature),"__")[,1][duplicated(strsplit2(unique(SES.masslin.all$feature),"__")[,1])]
SES.masslin.all$feature_update[SES.masslin.all$feature_update %in%dup.name] <- SES.masslin.all$feature[SES.masslin.all$feature_update %in%dup.name] 
SES.masslin.all$feature_update <- gsub("  "," ",gsub("_"," ",SES.masslin.all$feature_update))
SES.masslin.all <- unique(SES.masslin.all)

SES.masslin.all.use <- subset(SES.masslin.all, Normalization=="MCLR" & BFsub=="All" &
                                adjbasic=="ProcessingPeriod + exact_age" )

Generate bubble figure of pathways to compare the effect of BF and SES (Figure S3C)

######################################################################
#Longitudinal analysis results for SES & BF narrow down to focus - Bubble plot
################################################################################

bf.sig.use.main <- unique(c(subset(SES.masslin.all.use, 
                            qval<qval.ct & Model=="Nointeract"&
                              value%in%c("MR1_latent.raw","bf") & 
                              !value%in%exclude.val )$feature))
bf.sig.use.slope <-  unique(subset(SES.masslin.all.use, 
                            qval<qval.ct & Model=="Interact"&
                              check.var%in%c("MR1_latent.raw","bf") & value=="time_interaction"&
                              !value%in%exclude.val )$feature)
all.sp.bf <- rbind(subset(SES.masslin.all.use, !value%in%exclude.val & feature%in%bf.sig.use.slope & check.var%in%c("MR1_latent.raw","bf") & value=="time_interaction" & Model=="Interact"),
                   subset(SES.masslin.all.use, !value%in%exclude.val & feature%in%bf.sig.use.main & check.var%in%c("MR1_latent.raw","bf") &  value%in%c("MR1_latent.raw","bf")& Model=="Nointeract"))


all.sp.bf$U <- ifelse(all.sp.bf$qval<0.1,"*","")
all.sp.bf$Effect <- ifelse(all.sp.bf$value=="time_interaction","Slope",
                        ifelse(all.sp.bf$Model=="Interact", "Baseline",
                                ifelse(all.sp.bf$Model=="Nointeract", "Overall",NA)))
 
all.sp.bf <- merge(all.sp.bf, data.map, by.x="check.var", by.y="Vars",all.x=T)
all.sp.bf$Effect <- factor(all.sp.bf$Effect, levels=c( "Slope","Overall"), ordered=T)
all.sp.bf$Label[all.sp.bf$Label=="SES Index"] <- "SES"
all.sp.bf$Label <- factor(all.sp.bf$Label, levels=c( "SES","Breastfeeding"), ordered=T)
all.sp.bf$Direction <- ifelse(all.sp.bf$coef>0,"Positive","Negative")
all.sp.bf$sig <- ifelse(all.sp.bf$qval<0.1,"sig","nosig")
table(all.sp.bf$check.var,all.sp.bf$metadata,useNA = "ifany")
##                 
##                   bf MR1_latent.raw time_interaction
##   bf             235              0              231
##   MR1_latent.raw   0            235              231
#Dot plot
all.sp.bf.wide <- reshape2::dcast(all.sp.bf, feature +Effect ~ Label, value.var = "coef")
#To play add the mean relative
data.sp <- as.matrix(otu_table(RBMETA_MCLR))
data.meta <- data.frame(sample_data(RBMETA_MCLR))
data.sp.3m <- as.matrix(otu_table(subset_samples(RBMETA_MCLR, Visit=="3 month")))
data.sp.1y <- as.matrix(otu_table(subset_samples(RBMETA_MCLR, Visit=="1 year")))

rb.data <- merge(merge(data.frame(total_mean=apply(data.sp,2,mean)),
                       data.frame(m3_mean=apply(data.sp.3m,2,mean)), by="row.names"),
                 data.frame(y1_mean=apply(data.sp.1y,2,mean)),by.x="Row.names", by.y="row.names")

rb.data$Row.names <- gsub(" ","\\.",rb.data$Row.names)
all.sp.bf.wide <- merge(all.sp.bf.wide, rb.data, by.x="feature", by.y="Row.names",all.x=T)
data.sp.tax <- as.matrix(tax_table(RBMETA_MCLR))
rownames(data.sp.tax) <-  gsub(" ","\\.",rownames(data.sp.tax))
all.sp.bf.wide <- merge(all.sp.bf.wide,data.sp.tax ,by.x="feature", by.y="row.names")

sesbf.p <- ggplot(data=all.sp.bf.wide, aes(x=SES, y=Breastfeeding))  + 
  geom_hline(yintercept = 0, color="grey")+
  geom_vline(xintercept = 0, color="grey")+
  geom_point(aes(size=total_mean,color="black")) + #
  geom_smooth(method="lm", color="black")+ 
  scale_color_cosmic()+
  theme(aspect.ratio = 1)+
  facet_grid(~Effect,scale="free",space="free_y")+ 
  theme_bw()+
  stat_cor( geom = "label")


plot(sesbf.p)

pdf("Figures/P5 Maaslin2 Bubble figure of metacypathways for SES and BF.pdf", height=6, width=12)
plot(sesbf.p)
dev.off()
## quartz_off_screen 
##                 2